159 |
} |
} |
160 |
} |
} |
161 |
} |
} |
162 |
|
/** |
163 |
|
* \brief Mise à jour d'une ligne de produit |
164 |
|
* \param id id de la ligne |
165 |
|
* \param subprice prix unitaire |
166 |
|
* \param qty quantité |
167 |
|
* \param remise_percent remise effectuée sur le produit |
168 |
|
* \return int 0 en cas de succès |
169 |
|
*/ |
170 |
|
|
171 |
|
function UpdateLigne($id, $subprice, $qty, $remise_percent=0) |
172 |
|
{ |
173 |
|
if ($this->statut == 0) |
174 |
|
{ |
175 |
|
$price = $subprice; |
176 |
|
if ($remise_percent > 0) |
177 |
|
{ |
178 |
|
$remise = round(($subprice * $remise_percent / 100), 2); |
179 |
|
$price = $subprice - $remise; |
180 |
|
} |
181 |
|
|
182 |
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet "; |
183 |
|
$sql .= " SET qty='".$qty."'"; |
184 |
|
$sql .= " , price='". ereg_replace(",",".",$price)."'"; |
185 |
|
$sql .= " , remise_percent='".ereg_replace(",",".",$remise_percent)."'"; |
186 |
|
$sql .= " , subprice='".ereg_replace(",",".",$subprice)."'"; |
187 |
|
$sql .= " WHERE rowid = '".$id."';"; |
188 |
|
|
189 |
|
if ($this->db->query($sql) ) |
190 |
|
{ |
191 |
|
$this->update_price(); |
192 |
|
|
193 |
|
return 0; |
194 |
|
} |
195 |
|
else |
196 |
|
{ |
197 |
|
dolibarr_syslog("Propal::UpdateLigne Erreur -1"); |
198 |
|
return -1; |
199 |
|
} |
200 |
|
} |
201 |
|
else |
202 |
|
{ |
203 |
|
dolibarr_syslog("Propal::UpdateLigne Erreur -2 Propal en mode incompatible pour cette action"); |
204 |
|
return -2; |
205 |
|
} |
206 |
|
} |
207 |
/** |
/** |
208 |
* |
* |
209 |
* |
* |
210 |
*/ |
*/ |
211 |
|
|
212 |
function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx=19.6, $remise_percent=0) |
function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx=19.6, $remise_percent=0) |
213 |
{ |
{ |
214 |
if ($this->statut == 0) |
if ($this->statut == 0) |
215 |
{ |
{ |
216 |
if (strlen(trim($p_qty)) == 0) |
if (strlen(trim($p_qty)) == 0) |
217 |
{ |
{ |
218 |
$p_qty = 1; |
$p_qty = 1; |
219 |
} |
} |
220 |
|
|
221 |
$p_price = ereg_replace(",",".",$p_price); |
$p_price = ereg_replace(",",".",$p_price); |
222 |
|
|
223 |
$price = $p_price; |
$price = $p_price; |
347 |
} |
} |
348 |
} |
} |
349 |
else |
else |
350 |
{ |
{ |
351 |
dolibarr_print_error($this->db); |
//dolibarr_print_error($this->db); |
352 |
} |
} |
353 |
} |
} |
354 |
else |
else |
355 |
{ |
{ |
356 |
dolibarr_print_error($this->db); |
//dolibarr_print_error($this->db); |
357 |
} |
} |
358 |
return $this->id; |
return $this->id; |
359 |
} |
} |
418 |
* \brief Recupère de la base les caractéristiques d'une propale |
* \brief Recupère de la base les caractéristiques d'une propale |
419 |
* \param rowid id de la propal à récupérer |
* \param rowid id de la propal à récupérer |
420 |
*/ |
*/ |
421 |
function fetch($rowid) |
function fetch($rowid) |
422 |
{ |
{ |
423 |
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact,".$this->db->pdate("datep")."as dp,".$this->db->pdate("fin_validite")."as dfv, model_pdf, note, fk_projet, fk_statut, remise_percent, fk_user_author"; |
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact"; |
424 |
$sql .= ", c.label as statut_label"; |
$sql .= " ,".$this->db->pdate("datep")."as dp"; |
425 |
$sql .= " FROM ".MAIN_DB_PREFIX."propal"; |
$sql .= " ,".$this->db->pdate("fin_validite")."as dfv, model_pdf, note"; |
426 |
$sql .= "," . MAIN_DB_PREFIX."c_propalst as c"; |
$sql .= " , fk_projet, fk_statut, remise_percent, fk_user_author"; |
427 |
$sql .= " WHERE rowid=$rowid AND fk_statut = c.id"; |
$sql .= ", c.label as statut_label"; |
428 |
|
$sql .= " FROM ".MAIN_DB_PREFIX."propal"; |
429 |
$resql=$this->db->query($sql); |
$sql .= "," . MAIN_DB_PREFIX."c_propalst as c"; |
430 |
if ($resql) |
$sql .= " WHERE fk_statut = c.id"; |
431 |
{ |
$sql .= " AND rowid='".$rowid."';"; |
432 |
if ($this->db->num_rows($resql)) |
|
433 |
{ |
$resql=$this->db->query($sql); |
434 |
$obj = $this->db->fetch_object($resql); |
|
435 |
|
if ($resql) |
436 |
$this->id = $rowid; |
{ |
437 |
|
if ($this->db->num_rows($resql)) |
438 |
$this->datep = $obj->dp; |
{ |
439 |
$this->fin_validite = $obj->dfv; |
$obj = $this->db->fetch_object($resql); |
440 |
$this->date = $obj->dp; |
|
441 |
$this->ref = $obj->ref; |
$this->id = $rowid; |
442 |
$this->price = $obj->price; |
|
443 |
$this->remise = $obj->remise; |
$this->datep = $obj->dp; |
444 |
$this->remise_percent = $obj->remise_percent; |
$this->fin_validite = $obj->dfv; |
445 |
$this->total = $obj->total; |
$this->date = $obj->dp; |
446 |
$this->total_ht = $obj->price; |
$this->ref = $obj->ref; |
447 |
$this->total_tva = $obj->tva; |
$this->price = $obj->price; |
448 |
$this->total_ttc = $obj->total; |
$this->remise = $obj->remise; |
449 |
$this->socidp = $obj->fk_soc; |
$this->remise_percent = $obj->remise_percent; |
450 |
$this->soc_id = $obj->fk_soc; |
$this->total = $obj->total; |
451 |
$this->projetidp = $obj->fk_projet; |
$this->total_ht = $obj->price; |
452 |
$this->contactid = $obj->fk_soc_contact; |
$this->total_tva = $obj->tva; |
453 |
$this->modelpdf = $obj->model_pdf; |
$this->total_ttc = $obj->total; |
454 |
$this->note = $obj->note; |
$this->socidp = $obj->fk_soc; |
455 |
$this->statut = $obj->fk_statut; |
$this->soc_id = $obj->fk_soc; |
456 |
$this->statut_libelle = $obj->statut_label; |
$this->projetidp = $obj->fk_projet; |
457 |
|
$this->contactid = $obj->fk_soc_contact; |
458 |
$this->user_author_id = $obj->fk_user_author; |
$this->modelpdf = $obj->model_pdf; |
459 |
|
$this->note = $obj->note; |
460 |
if ($obj->fk_statut == 0) |
$this->statut = $obj->fk_statut; |
461 |
{ |
$this->statut_libelle = $obj->statut_label; |
462 |
$this->brouillon = 1; |
|
463 |
} |
$this->user_author_id = $obj->fk_user_author; |
464 |
|
|
465 |
$this->lignes = array(); |
if ($obj->fk_statut == 0) |
466 |
$this->db->free(); |
{ |
467 |
|
$this->brouillon = 1; |
468 |
$this->ref_url = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$this->id.'">'.$this->ref.'</a>'; |
} |
|
|
|
|
/* |
|
|
* Lignes produits |
|
|
*/ |
|
|
|
|
|
$sql = "SELECT p.rowid, p.label, p.description, p.ref, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice"; |
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."product as p"; |
|
|
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid ORDER by d.rowid ASC"; |
|
|
|
|
|
$result = $this->db->query($sql); |
|
|
if ($result) |
|
|
{ |
|
|
$num = $this->db->num_rows($result); |
|
|
$i = 0; |
|
|
|
|
|
while ($i < $num) |
|
|
{ |
|
|
$objp = $this->db->fetch_object($result); |
|
|
|
|
|
$ligne = new PropaleLigne(); |
|
|
$ligne->libelle = stripslashes($objp->label); |
|
|
$ligne->desc = stripslashes($objp->description); |
|
|
$ligne->qty = $objp->qty; |
|
|
$ligne->ref = $objp->ref; |
|
|
$ligne->tva_tx = $objp->tva_tx; |
|
|
$ligne->subprice = $objp->subprice; |
|
|
$ligne->remise_percent = $objp->remise_percent; |
|
|
$ligne->price = $objp->price; |
|
|
$ligne->product_id = $objp->rowid; |
|
|
|
|
|
$this->lignes[$i] = $ligne; |
|
|
$i++; |
|
|
} |
|
|
$this->db->free($result); |
|
|
} |
|
|
else |
|
|
{ |
|
|
dolibarr_print_error($this->db); |
|
|
return -1; |
|
|
} |
|
|
|
|
|
/* |
|
|
* Lignes propales |
|
|
*/ |
|
|
$sql = "SELECT d.qty, d.description, d.price, d.subprice, d.tva_tx, d.rowid, d.remise_percent"; |
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d"; |
|
|
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = 0"; |
|
|
|
|
|
$result = $this->db->query($sql); |
|
|
if ($result) |
|
|
{ |
|
|
$num = $this->db->num_rows($result); |
|
|
$j = 0; |
|
469 |
|
|
470 |
while ($j < $num) |
$this->lignes = array(); |
471 |
{ |
$this->db->free($resql); |
472 |
$objp = $this->db->fetch_object($result); |
|
473 |
$ligne = new PropaleLigne(); |
$this->ref_url = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$this->id.'">'.$this->ref.'</a>'; |
|
$ligne->libelle = stripslashes($objp->description); |
|
|
$ligne->desc = stripslashes($objp->description); |
|
|
$ligne->qty = $objp->qty; |
|
|
$ligne->ref = $objp->ref; |
|
|
$ligne->tva_tx = $objp->tva_tx; |
|
|
$ligne->subprice = $objp->subprice; |
|
|
$ligne->remise_percent = $objp->remise_percent; |
|
|
$ligne->price = $objp->price; |
|
|
$ligne->product_id = 0; |
|
|
|
|
|
$this->lignes[$i] = $ligne; |
|
|
$i++; |
|
|
$j++; |
|
|
} |
|
474 |
|
|
475 |
$this->db->free($result); |
/* |
476 |
} |
* Lignes produits |
477 |
else |
*/ |
478 |
{ |
|
479 |
dolibarr_print_error($this->db); |
$sql = "SELECT p.rowid, p.label, p.description, p.ref, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice"; |
480 |
return -1; |
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."product as p"; |
481 |
} |
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid ORDER by d.rowid ASC"; |
482 |
} |
|
483 |
return 1; |
$result = $this->db->query($sql); |
484 |
} |
if ($result) |
485 |
else |
{ |
486 |
{ |
$num = $this->db->num_rows($result); |
487 |
dolibarr_print_error($this->db); |
$i = 0; |
488 |
return -1; |
|
489 |
} |
while ($i < $num) |
490 |
} |
{ |
491 |
|
$objp = $this->db->fetch_object($result); |
492 |
|
|
493 |
|
$ligne = new PropaleLigne(); |
494 |
|
$ligne->libelle = stripslashes($objp->label); |
495 |
|
$ligne->desc = stripslashes($objp->description); |
496 |
|
$ligne->qty = $objp->qty; |
497 |
|
$ligne->ref = $objp->ref; |
498 |
|
$ligne->tva_tx = $objp->tva_tx; |
499 |
|
$ligne->subprice = $objp->subprice; |
500 |
|
$ligne->remise_percent = $objp->remise_percent; |
501 |
|
$ligne->price = $objp->price; |
502 |
|
$ligne->product_id = $objp->rowid; |
503 |
|
|
504 |
|
$this->lignes[$i] = $ligne; |
505 |
|
$i++; |
506 |
|
} |
507 |
|
$this->db->free($result); |
508 |
|
} |
509 |
|
else |
510 |
|
{ |
511 |
|
dolibarr_syslog("Propal::Fetch Erreur lecture des produits"); |
512 |
|
return -1; |
513 |
|
} |
514 |
|
|
515 |
|
/* |
516 |
|
* Lignes propales |
517 |
|
*/ |
518 |
|
$sql = "SELECT d.qty, d.description, d.price, d.subprice, d.tva_tx, d.rowid, d.remise_percent"; |
519 |
|
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d"; |
520 |
|
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = 0"; |
521 |
|
|
522 |
|
$result = $this->db->query($sql); |
523 |
|
if ($result) |
524 |
|
{ |
525 |
|
$num = $this->db->num_rows($result); |
526 |
|
$j = 0; |
527 |
|
|
528 |
|
while ($j < $num) |
529 |
|
{ |
530 |
|
$objp = $this->db->fetch_object($result); |
531 |
|
$ligne = new PropaleLigne(); |
532 |
|
$ligne->libelle = stripslashes($objp->description); |
533 |
|
$ligne->desc = stripslashes($objp->description); |
534 |
|
$ligne->qty = $objp->qty; |
535 |
|
$ligne->ref = $objp->ref; |
536 |
|
$ligne->tva_tx = $objp->tva_tx; |
537 |
|
$ligne->subprice = $objp->subprice; |
538 |
|
$ligne->remise_percent = $objp->remise_percent; |
539 |
|
$ligne->price = $objp->price; |
540 |
|
$ligne->product_id = 0; |
541 |
|
|
542 |
|
$this->lignes[$i] = $ligne; |
543 |
|
$i++; |
544 |
|
$j++; |
545 |
|
} |
546 |
|
|
547 |
|
$this->db->free($result); |
548 |
|
} |
549 |
|
else |
550 |
|
{ |
551 |
|
dolibarr_syslog("Propal::Fetch Erreur lecture des lignes de propale"); |
552 |
|
|
553 |
|
return -1; |
554 |
|
} |
555 |
|
} |
556 |
|
return 1; |
557 |
|
} |
558 |
|
else |
559 |
|
{ |
560 |
|
dolibarr_syslog("Propal::Fetch Erreur lecture de la propale $rowid"); |
561 |
|
return -1; |
562 |
|
} |
563 |
|
} |
564 |
|
|
565 |
/* |
/* |
566 |
* |
* |
567 |
* |
* |
582 |
} |
} |
583 |
else |
else |
584 |
{ |
{ |
585 |
dolibarr_print_error($this->db); |
//dolibarr_print_error($this->db); |
586 |
return -1; |
return -1; |
587 |
} |
} |
588 |
} |
} |
595 |
*/ |
*/ |
596 |
|
|
597 |
function set_remise($user, $remise) |
function set_remise($user, $remise) |
598 |
{ |
{ |
599 |
if ($user->rights->propale->creer) |
if ($user->rights->propale->creer) |
600 |
{ |
{ |
601 |
$remise = ereg_replace(",",".",$remise); |
$remise = ereg_replace(",",".",$remise); |
602 |
|
|
603 |
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise; |
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise; |
604 |
$sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;"; |
$sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;"; |
605 |
|
|
606 |
if ($this->db->query($sql) ) |
if ($this->db->query($sql) ) |
607 |
{ |
{ |
608 |
$this->remise_percent = $remise; |
$this->remise_percent = $remise; |
609 |
$this->update_price(); |
$this->update_price(); |
610 |
return 1; |
return 1; |
611 |
} |
} |
612 |
else |
else |
613 |
{ |
{ |
614 |
dolibarr_print_error($this->db); |
dolibarr_syslog("Propal::set_remise Erreur SQL"); |
615 |
} |
} |
616 |
} |
} |
617 |
} |
} |
618 |
|
|
619 |
/* |
/* |
620 |
* |
* |
621 |
* |
* |
622 |
* |
* |
623 |
*/ |
*/ |
624 |
|
|
625 |
function set_project($user, $project_id) |
function set_project($user, $project_id) |
626 |
{ |
{ |
627 |
if ($user->rights->propale->creer) |
if ($user->rights->propale->creer) |
628 |
{ |
{ |
629 |
//verif que le projet et la société concordent |
//verif que le projet et la société concordent |
630 |
$sql = 'SELECT p.rowid, p.title FROM '.MAIN_DB_PREFIX.'projet as p WHERE p.fk_soc ='.$this->socidp.' AND p.rowid='.$project_id; |
$sql = 'SELECT p.rowid, p.title FROM '.MAIN_DB_PREFIX.'projet as p WHERE p.fk_soc ='.$this->socidp.' AND p.rowid='.$project_id; |
631 |
$sqlres = $this->db->query($sql); |
$sqlres = $this->db->query($sql); |
632 |
if ($sqlres) |
if ($sqlres) |
633 |
{ |
{ |
634 |
$numprojet = $this->db->num_rows($sqlres); |
$numprojet = $this->db->num_rows($sqlres); |
635 |
if ($numprojet > 0) |
if ($numprojet > 0) |
636 |
{ |
{ |
637 |
$this->projetidp=$project_id; |
$this->projetidp=$project_id; |
638 |
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_projet = '.$project_id; |
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_projet = '.$project_id; |
639 |
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; |
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; |
640 |
$this->db->query($sql); |
$this->db->query($sql); |
641 |
} |
} |
642 |
} |
} |
643 |
else |
else |
644 |
{ |
{ |
645 |
dolibarr_print_error($this->db); |
|
646 |
} |
dolibarr_syslog("Propal::set_project Erreur SQL"); |
647 |
} |
} |
648 |
} |
} |
649 |
|
} |
650 |
|
|
651 |
/* |
/* |
652 |
* |
* |
653 |
* |
* |
654 |
* |
* |
655 |
*/ |
*/ |
656 |
|
|
657 |
function set_contact($user, $contact_id) |
function set_contact($user, $contact_id) |
658 |
{ |
{ |
659 |
if ($user->rights->propale->creer) |
if ($user->rights->propale->creer) |
660 |
{ |
{ |
661 |
//verif que le contact et la société concordent |
//verif que le contact et la société concordent |
662 |
$sql = 'SELECT p.idp FROM '.MAIN_DB_PREFIX.'socpeople as p WHERE p.fk_soc = '.$this->socidp.' AND p.idp='.$contact_id; |
$sql = 'SELECT p.idp FROM '.MAIN_DB_PREFIX.'socpeople as p WHERE p.fk_soc = '.$this->socidp.' AND p.idp='.$contact_id; |
663 |
$sqlres = $this->db->query($sql); |
$sqlres = $this->db->query($sql); |
664 |
if ($sqlres) |
if ($sqlres) |
665 |
{ |
{ |
666 |
$numprojet = $this->db->num_rows($sqlres); |
$numprojet = $this->db->num_rows($sqlres); |
667 |
if ($numprojet > 0) |
if ($numprojet > 0) |
668 |
{ |
{ |
669 |
$this->projetidp=$project_id; |
$this->projetidp=$project_id; |
670 |
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_soc_contact = '.$contact_id; |
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_soc_contact = '.$contact_id; |
671 |
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; |
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; |
672 |
$this->db->query($sql); |
$this->db->query($sql); |
673 |
} |
} |
674 |
} |
} |
675 |
else |
else |
676 |
{ |
{ |
677 |
dolibarr_print_error($this->db); |
dolibarr_syslog("Propal::set_contact Erreur SQL"); |
678 |
} |
} |
679 |
} |
} |
680 |
} |
} |
681 |
|
|
682 |
/* |
/* |
683 |
* |
* |
684 |
* |
* |
974 |
*/ |
*/ |
975 |
|
|
976 |
function update_note($note) |
function update_note($note) |
977 |
{ |
{ |
978 |
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET note = '$note'"; |
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET note = '$note'"; |
979 |
$sql .= " WHERE rowid = $this->id;"; |
$sql .= " WHERE rowid = $this->id;"; |
|
|
|
|
if ($this->db->query($sql) ) |
|
|
{ |
|
|
return 1; |
|
|
} |
|
|
else |
|
|
{ |
|
|
dolibarr_print_error($this->db); |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
* \brief Information sur l'objet propal |
|
|
* \param id id de la propale |
|
|
*/ |
|
|
function info($id) |
|
|
{ |
|
|
$sql = "SELECT c.rowid, "; |
|
|
$sql.= $this->db->pdate("datec")." as datec, ".$this->db->pdate("date_valid")." as datev, ".$this->db->pdate("date_cloture")." as dateo"; |
|
|
$sql.= ", fk_user_author, fk_user_valid, fk_user_cloture"; |
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; |
|
|
$sql.= " WHERE c.rowid = $id"; |
|
|
|
|
|
if ($this->db->query($sql)) |
|
|
{ |
|
|
if ($this->db->num_rows()) |
|
|
{ |
|
|
$obj = $this->db->fetch_object(); |
|
|
|
|
|
$this->id = $obj->rowid; |
|
|
|
|
|
$this->date_creation = $obj->datec; |
|
|
$this->date_validation = $obj->datev; |
|
|
$this->date_cloture = $obj->dateo; |
|
|
|
|
|
$cuser = new User($this->db, $obj->fk_user_author); |
|
|
$cuser->fetch(); |
|
|
$this->user_creation = $cuser; |
|
|
|
|
|
if ($obj->fk_user_valid) |
|
|
{ |
|
|
$vuser = new User($this->db, $obj->fk_user_valid); |
|
|
$vuser->fetch(); |
|
|
$this->user_validation = $vuser; |
|
|
} |
|
|
|
|
|
if ($obj->fk_user_cloture) |
|
|
{ |
|
|
$cluser = new User($this->db, $obj->fk_user_cloture); |
|
|
$cluser->fetch(); |
|
|
$this->user_cloture = $cluser; |
|
|
} |
|
|
|
|
980 |
|
|
981 |
} |
if ($this->db->query($sql) ) |
982 |
$this->db->free(); |
{ |
983 |
|
return 1; |
984 |
|
} |
985 |
|
else |
986 |
|
{ |
987 |
|
dolibarr_print_error($this->db); |
988 |
|
return -1; |
989 |
|
} |
990 |
|
} |
991 |
|
|
992 |
|
|
993 |
|
/** |
994 |
|
* \brief Information sur l'objet propal |
995 |
|
* \param id id de la propale |
996 |
|
*/ |
997 |
|
function info($id) |
998 |
|
{ |
999 |
|
$sql = "SELECT c.rowid, "; |
1000 |
|
$sql.= $this->db->pdate("datec")." as datec, ".$this->db->pdate("date_valid")." as datev, ".$this->db->pdate("date_cloture")." as dateo"; |
1001 |
|
$sql.= ", fk_user_author, fk_user_valid, fk_user_cloture"; |
1002 |
|
$sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; |
1003 |
|
$sql.= " WHERE c.rowid = $id"; |
1004 |
|
|
1005 |
} |
if ($this->db->query($sql)) |
1006 |
else |
{ |
1007 |
{ |
if ($this->db->num_rows()) |
1008 |
dolibarr_print_error($this->db); |
{ |
1009 |
} |
$obj = $this->db->fetch_object(); |
1010 |
} |
|
1011 |
|
$this->id = $obj->rowid; |
1012 |
|
|
1013 |
|
$this->date_creation = $obj->datec; |
1014 |
|
$this->date_validation = $obj->datev; |
1015 |
|
$this->date_cloture = $obj->dateo; |
1016 |
|
|
1017 |
|
$cuser = new User($this->db, $obj->fk_user_author); |
1018 |
|
$cuser->fetch(); |
1019 |
|
$this->user_creation = $cuser; |
1020 |
|
|
1021 |
|
if ($obj->fk_user_valid) |
1022 |
|
{ |
1023 |
|
$vuser = new User($this->db, $obj->fk_user_valid); |
1024 |
|
$vuser->fetch(); |
1025 |
|
$this->user_validation = $vuser; |
1026 |
|
} |
1027 |
|
|
1028 |
|
if ($obj->fk_user_cloture) |
1029 |
|
{ |
1030 |
|
$cluser = new User($this->db, $obj->fk_user_cloture); |
1031 |
|
$cluser->fetch(); |
1032 |
|
$this->user_cloture = $cluser; |
1033 |
|
} |
1034 |
|
|
1035 |
|
|
1036 |
|
} |
1037 |
|
$this->db->free(); |
1038 |
|
|
1039 |
|
} |
1040 |
|
else |
1041 |
|
{ |
1042 |
|
dolibarr_print_error($this->db); |
1043 |
|
} |
1044 |
|
} |
1045 |
|
|
1046 |
|
|
1047 |
/** |
/** |
1048 |
* \brief Retourne le libellé du statut d'une propale (brouillon, validée, ...) |
* \brief Retourne le libellé du statut d'une propale (brouillon, validée, ...) |
1049 |
* \return string Libellé |
* \return string Libellé |
1050 |
*/ |
*/ |
1051 |
function getLibStatut() |
function getLibStatut() |
1052 |
{ |
{ |
1053 |
return $this->LibStatut($this->statut); |
return $this->LibStatut($this->statut); |
1054 |
} |
} |
1055 |
|
|
1056 |
/** |
/** |
1057 |
* \brief Renvoi le libellé d'un statut donné |
* \brief Renvoi le libellé d'un statut donné |
1058 |
* \param statut id statut |
* \param statut id statut |
1059 |
* \param size Libellé court si 0, long si non défini |
* \param size Libellé court si 0, long si non défini |
1060 |
* \return string Libellé |
* \return string Libellé |
1061 |
*/ |
*/ |
1062 |
function LibStatut($statut,$size=1) |
function LibStatut($statut,$size=1) |
1063 |
{ |
{ |
1064 |
if ($size) return $this->labelstatut[$statut]; |
if ($size) return $this->labelstatut[$statut]; |
1065 |
else return $this->labelstatut_short[$statut]; |
else return $this->labelstatut_short[$statut]; |
1066 |
} |
} |
1067 |
|
|
1068 |
} |
} |
1069 |
|
|
1070 |
class PropaleLigne |
class PropaleLigne |
1071 |
{ |
{ |
1072 |
function PropaleLigne() |
function PropaleLigne() |
1073 |
{ |
{ |
1074 |
} |
} |
1075 |
} |
} |
1076 |
?> |
?> |