diff --git a/dev/load/generate-facture.php b/dev/load/generate-facture.php index 040e37a5534..f0894a1ef17 100644 --- a/dev/load/generate-facture.php +++ b/dev/load/generate-facture.php @@ -115,7 +115,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0) $result=$facture->create($user); if ($result >= 0) { - $result=$facture->set_valid($facture->id,$user,$socid); + $result=$facture->set_valid($user,$socid); if ($result) print " OK"; else { diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index 9f6ec5c6c8e..0fb6256f8bc 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -50,12 +50,13 @@ class ActionComm var $datep; // Date action planifie debut (datep) var $datef; // Date action planifie fin (datep2) - var $date; // Date action realise debut (datea) - var $dateend; // Date action realise fin (datea2) var $durationp = -1; - var $durationa = -1; + //var $date; // Date action realise debut (datea) // deprecated + //var $dateend; // Date action realise fin (datea2) // deprecated + var $durationa = -1; // deprecated var $priority; - + var $punctual = 1; + var $usertodo; // Object user that must do action var $userdone; // Object user that did action @@ -98,6 +99,7 @@ class ActionComm $this->note=trim($this->note); if (! $this->percentage) $this->percentage = 0; if (! $this->priority) $this->priority = 0; + if (! $this->punctual) $this->punctual = 0; if ($this->percentage > 100) $this->percentage = 100; if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; if ($this->datep && $this->datef) $this->durationp=($this->datef - $this->datep); @@ -145,7 +147,7 @@ class ActionComm $sql.= "fk_user_author,"; $sql.= "fk_user_action,"; $sql.= "fk_user_done,"; - $sql.= "label,percent,priority,"; + $sql.= "label,percent,priority,punctual,"; $sql.= "fk_facture,propalrowid,fk_commande)"; $sql.= " VALUES ("; $sql.= "'".$this->db->idate($now)."',"; @@ -160,7 +162,7 @@ class ActionComm $sql.= "'".$user->id."',"; $sql.= ($this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").","; $sql.= ($this->userdone->id > 0?"'".$this->userdone->id."'":"null").","; - $sql.= "'".addslashes($this->label)."','".$this->percentage."','".$this->priority."',"; + $sql.= "'".addslashes($this->label)."','".$this->percentage."','".$this->priority."','".$this->punctual."',"; $sql.= ($this->facid?$this->facid:"null").","; $sql.= ($this->propalrowid?$this->propalrowid:"null").","; $sql.= ($this->orderrowid?$this->orderrowid:"null"); diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index ba0298151fc..f7dfaa323fc 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -17,7 +17,7 @@ */ /** - \file htdocs/admin/agenda_actions.php + \file htdocs/admin/agenda.php \ingroup agenda \brief Autocreate actions for agenda module setup page \version $Id$ @@ -49,6 +49,8 @@ $eventstolog=array( array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled), array('id'=>'BILL_CANCELED', 'test'=>$conf->facture->enabled), array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled), + array('id'=>'ORDER_SUPPLIER_VALIDATE','test'=>$conf->fournisseur->enabled), + array('id'=>'BILL_SUPPLIER_VALIDATE', 'test'=>$conf->fournisseur->enabled), // array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled), // array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled), // array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled), diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index a6f7471060f..f29d61ad4b3 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -624,13 +624,10 @@ if ($_GET["id"]) $html->select_array("contactid", $act->societe->contact_array(), $act->contact->id, 1); print ''; - // Priorite - print ''.$langs->trans("Priority").''; - print ''; - print ''; + print '
'; // Input by - print ''; @@ -644,8 +641,10 @@ if ($_GET["id"]) $html->select_users($act->userdone->id,'doneby',1); print ''; + print '
'.$langs->trans("ActionAskedBy").''; + print '
'.$langs->trans("ActionAskedBy").''; print $act->author->getNomUrl(1); print '

'; + // Date start - print ''; + // Priorite + print ''; + // Status print ''; @@ -675,7 +679,7 @@ if ($_GET["id"]) { // Editeur wysiwyg require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note',$act->note,280,'dolibarr_notes','In',true); + $doleditor=new DolEditor('note',$act->note,240,'dolibarr_notes','In',true); $doleditor->Create(); } else @@ -720,13 +724,10 @@ if ($_GET["id"]) print ''; - // Priorite - print ''; + print '
'.$langs->trans("DateActionStart").''; + print '
'.$langs->trans("DateActionStart").''; if ($_REQUEST["afaire"] == 1) $html->select_date($act->datep,'ap',1,1,0,"action"); else if ($_REQUEST["afaire"] == 2) $html->select_date($act->datep,'ap',1,1,1,"action"); else $html->select_date($act->datep,'ap',1,1,1,"action"); @@ -659,6 +658,11 @@ if ($_GET["id"]) if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < (time() - $conf->global->MAIN_DELAY_ACTIONS_TODO)) print img_warning($langs->trans("Late")); print '
'.$langs->trans("Priority").''; + print ''; + print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").'percentage).'" size="4">%
'.$langs->trans("Priority").''; - print $act->priority; - print '

'; // Input by - print ''; @@ -740,8 +741,10 @@ if ($_GET["id"]) if ($act->userdone->id > 0) print $act->userdone->getNomUrl(1); print ''; + print '
'.$langs->trans("ActionAskedBy").''; + print '
'.$langs->trans("ActionAskedBy").''; print $act->author->getNomUrl(1); print '

'; + // Date debut - print ''; @@ -752,6 +755,11 @@ if ($_GET["id"]) if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < (time() - $conf->global->MAIN_DELAY_ACTIONS_TODO)) print img_warning($langs->trans("Late")); print ''; + // Priorite + print ''; + // Statut print '
'.$langs->trans("DateActionStart").''; + print '
'.$langs->trans("DateActionStart").''; print dolibarr_print_date($act->datep,'dayhour'); if ($act->percentage == 0 && $act->datep && $act->datep < (time() - $conf->global->MAIN_DELAY_ACTIONS_TODO)) print img_warning($langs->trans("Late")); print '
'.$langs->trans("Priority").''; + print $act->priority; + print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; print $act->getLibStatut(4); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e946aeb2012..9fc8d89197c 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -469,7 +469,7 @@ if ($_GET['action'] == 'modif' && $user->rights->propale->creer) */ $propal = new Propal($db); $propal->fetch($_GET['propalid']); - $propal->set_draft($user->id); + $propal->set_draft($user); } if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer) @@ -1703,53 +1703,10 @@ if ($_GET['propalid'] > 0) print ''; - /* - * Liste des actions propres a la propal - */ - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - { - $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql .= ' WHERE a.propalrowid = '.$propal->id ; - if ($socid) $sql .= ' AND a.fk_soc = '.$socid; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num) - { - print_titre($langs->trans('ActionsOnPropal')); - $i = 0; - $total = 0; - $var=true; - - print ''; - print ''; - print "\n"; - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - print '\n"; - print ''; - $authoract = new User($db); - $authoract->id = $objp->fk_user_author; - $authoract->fetch(''); - print ''; - print "\n"; - $i++; - } - print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da)."'.stripslashes($objp->label).''.$authoract->login.'
'; - } - } - else - { - dolibarr_print_error($db); - } - } + // List of actions on element + include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($propal,'propal',$socid); print '
'; diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 9216e68e720..aa016b4774f 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -317,16 +317,17 @@ class Commande extends CommonObject return -1; } - /** - * - * - */ - function set_draft($user) - { - global $conf; + /** + * \brief Set draft status + * \param user Object user that modify + * \param int <0 if KO, >0 if OK + */ + function set_draft($user) + { + global $conf,$langs; $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0"; - $sql .= " WHERE rowid = $this->id;"; + $sql .= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) { diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index f85f21503d3..41b1efcb28c 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -444,19 +444,19 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->valider) { - $commande = new Commande($db); - $commande->fetch($_GET['id']); - $soc = new Societe($db); - $soc->fetch($commande->socid); - if ($_REQUEST['lang_id']) + $commande = new Commande($db); + $commande->fetch($_GET['id']); + + $result=$commande->valid($user); + if ($result >= 0) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); } - commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); - $result=$commande->valid($user); - Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']); - exit; } if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->creer) @@ -615,22 +615,16 @@ if ($_POST['action'] == 'send') if ($_POST['action'] == 'send') { - $subject = $_POST['subject']; - - if($subject == '') - { - $subject = $langs->transnoentities('Order').' '.$commande->ref; - } - + if (strlen($_POST['subject'])) $subject=$_POST['subject']; + else $subject = $langs->transnoentities('Order').' '.$commande->ref; $actiontypecode='AC_COM'; $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - if ($message) { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; $actionmsg.=$message; } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } @@ -1864,54 +1858,10 @@ else } print ''; - /* - * Liste des actions propres a la commande - */ - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - { - $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql .= ' WHERE a.fk_commande = '.$commande->id ; - if ($socid) $sql .= ' AND a.fk_soc = '.$socid; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num) - { - //print '
'; - print_titre($langs->trans('ActionsOnOrder')); - $i = 0; - $total = 0; - $var=true; - - print ''; - print ''; - print "\n"; - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - print '\n"; - print ''; - $authoract = new User($db); - $authoract->id = $objp->fk_user_author; - $authoract->fetch(''); - print ''; - print "\n"; - $i++; - } - print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da,'day')."'.stripslashes($objp->label).''.$authoract->login.'
'; - } - } - else - { - dolibarr_print_error($db); - } - } + // List of actions on element + include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($commande,'order',$socid); print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index bb543a47f8a..8f1f4492c83 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -239,7 +239,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user-> $fac->fetch($_GET['facid']); $fac->fetch_client(); - $result = $fac->set_valid($fac->id, $user); + $result = $fac->set_valid($user); if ($result >= 0) { if ($_REQUEST['lang_id']) @@ -2954,54 +2954,11 @@ else print ''; - /* - * Liste des actions propres à la facture - * Action 9 and 10 are implicits actions. Do not protect this section according - * to agenda module permissions. - */ - $sql = 'SELECT a.id, '.$db->pdate('a.datea').' as da, a.label, a.note,'; - $sql.= ' u.login'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a, '.MAIN_DB_PREFIX.'user as u'; - $sql.= ' WHERE a.fk_user_author = u.rowid'; - $sql.= ' AND a.fk_action in (9,10)'; - $sql.= ' AND a.fk_soc = '.$fac->socid ; - $sql.= ' AND a.fk_facture = '.$fac->id; - - dolibarr_syslog("compta/facture.php sql=".$sql); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num) - { - print '
'; - print_titre($langs->trans('ActionsOnBill')); - - $i = 0; $total = 0; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da,'day').''.$objp->label.''.$objp->login.'
'; - } - } - else - { - dolibarr_print_error($db); - } + // List of actions on element + include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($fac,'invoice',$socid); + print ''; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 8c9d71a6792..dd7e82eabc3 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -987,13 +987,12 @@ class Facture extends CommonObject /** * \brief Tag la facture comme validée + appel trigger BILL_VALIDATE - * \param rowid Id de la facture à valider * \param user Utilisateur qui valide la facture * \param soc Ne sert plus \\TODO A virer * \param force_number Référence à forcer de la facture * \return int <0 si ko, >0 si ok */ - function set_valid($rowid, $user, $soc='', $force_number='') + function set_valid($user, $soc='', $force_number='') { global $conf,$langs; @@ -1027,7 +1026,7 @@ class Facture extends CommonObject // Controle que facture source non deja remplacee par une autre $idreplacement=$facreplaced->getIdReplacingInvoice('validated'); - if ($idreplacement && $idreplacement != $rowid) + if ($idreplacement && $idreplacement != $this->id) { $facreplacement=new Facture($this->db); $facreplacement->fetch($idreplacement); @@ -1075,7 +1074,7 @@ class Facture extends CommonObject $sql.= ', datef='.$this->db->idate($this->date); $sql.= ', date_lim_reglement='.$this->db->idate($datelim); } - $sql.= ' WHERE rowid = '.$rowid; + $sql.= ' WHERE rowid = '.$this->id; $resql=$this->db->query($sql); if ($resql) { @@ -1192,15 +1191,17 @@ class Facture extends CommonObject /** * \brief Set draft status - * \param userid Id user setting + * \param user Object user that modify + * \param int <0 if KO, >0 if OK */ - function set_draft($userid) + function set_draft($user) { - dolibarr_syslog("Facture::set_draft rowid=".$this->id, LOG_DEBUG); + global $conf,$langs; $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id; + dolibarr_syslog("Facture::set_draft sql=".$sql, LOG_DEBUG); if ($this->db->query($sql)) { return 1; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 6913ba61b00..e6185bfc535 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -217,17 +217,19 @@ if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->valider) { - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET['id']); - $soc = new Societe($db); - $soc->fetch($commande->socid); - $result = $commande->valid($user); - if ($result >= 0) - { - supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); - Header("Location: fiche.php?id=".$_GET["id"]); - exit; - } + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET['id']); + + $result = $commande->valid($user); + if ($result >= 0) + { + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + } } if ($_POST['action'] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver) @@ -235,11 +237,6 @@ if ($_POST['action'] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user $commande = new CommandeFournisseur($db); $commande->fetch($_GET['id']); $result = $commande->approve($user); - if ($result >= 0) - { - Header("Location: fiche.php?id=".$_GET["id"]); - exit; - } } if ($_POST['action'] == 'confirm_refuse' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->approuver) @@ -247,11 +244,6 @@ if ($_POST['action'] == 'confirm_refuse' && $_POST['confirm'] == 'yes' && $user- $commande = new CommandeFournisseur($db); $commande->fetch($_GET['id']); $result = $commande->refuse($user); - if ($result >= 0) - { - Header("Location: fiche.php?id=".$_GET["id"]); - exit; - } } if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->commander) @@ -259,8 +251,6 @@ if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $use $commande = new CommandeFournisseur($db); $commande->fetch($_GET["id"]); $result = $commande->commande($user, $_GET["datecommande"], $_GET["methode"]); - Header("Location: fiche.php?id=".$_GET["id"]); - exit; } diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 816ca880cb1..9cf64aa10fe 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -41,7 +41,7 @@ $langs->load('bills'); $langs->load('suppliers'); $langs->load('companies'); -// S�curit� acc�s client +// Security check if ($user->societe_id > 0) { $action = ''; @@ -57,9 +57,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user-> { $facturefourn=new FactureFournisseur($db); $facturefourn->fetch($_GET['facid']); - $facturefourn->set_valid($user); - Header('Location: fiche.php?facid='.$_GET['facid']); - exit; + $result = $facturefourn->set_valid($user); } if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index ddebf8cccbf..81dc343c17b 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -82,6 +82,7 @@ class CommandeFournisseur extends Commande $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm.rowid = c.fk_methode_commande"; $sql .= " WHERE c.rowid = ".$id; + dolibarr_syslog("CommandeFournisseur::fetch sql=".$sql,LOG_DEBUG); $resql = $this->db->query($sql) ; if ($resql) { diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index 36826a06cf7..d0cde2db6e1 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -382,17 +382,34 @@ class FactureFournisseur extends Facture */ function set_valid($user) { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; + global $conf,$langs; + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; $sql.= " SET fk_statut = 1, fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; + + dolibarr_syslog("FactureFournisseur::set_valid sql=".$sql,LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if ($resql) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('BILL_SUPPLIER_VALIDATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + + $this->db->commit(); + return 1; + } + else { $this->error=$this->db->error(); - dolibarr_print_error($this->db); + $this->db->rollback(); return -1; } - return 1; } diff --git a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php index 50ffb4095a6..03801cb1c59 100644 --- a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php +++ b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php @@ -289,8 +289,38 @@ class InterfaceActionsAuto $object->orderrowid=$object->propalrowid=0; $ok=1; } + elseif ($action == 'ORDER_SUPPLIER_VALIDATE') + { + dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $langs->load("orders"); + $langs->load("agenda"); + + $object->actiontypecode='AC_OTH'; + $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); + $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; - + $object->sendtoid=0; + $object->orderrowid=0; // Supplier order not yet supported + $object->propalrowid=$object->facid=0; + $ok=1; + } + elseif ($action == 'BILL_SUPPLIER_VALIDATE') + { + dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $langs->load("bills"); + $langs->load("agenda"); + + $object->actiontypecode='AC_OTH'; + $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); + $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + + $object->sendtoid=0; + $object->facid=0; // Supplier invoice not yet supported + $object->orderrowid=$object->propalrowid=0; + $ok=1; + } // If not found @@ -305,6 +335,8 @@ class InterfaceActionsAuto // Add entry in event table if ($ok) { + $now=time(); + // Insertion action require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php'); @@ -312,7 +344,10 @@ class InterfaceActionsAuto $actioncomm->type_code = $object->actiontypecode; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; - $actioncomm->date = time(); // L'action est faite maintenant + $actioncomm->datep = $now; + $actioncomm->datef = $now; + $actioncomm->durationp = 0; + $actioncomm->punctual = 1; $actioncomm->percentage = 100; $actioncomm->contact = new Contact($this->db,$object->sendtoid); $actioncomm->societe = new Societe($this->db,$object->socid); @@ -331,7 +366,7 @@ class InterfaceActionsAuto $error ="Failed to insert : ".$actioncomm->error." "; $this->error=$error; - //dolibarr_syslog("interface_webcal.class.php: ".$this->error); + dolibarr_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error); return -1; } } diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 3e66bd8bb2f..72914d3777a 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -1130,23 +1130,25 @@ class Propal extends CommonObject } - /** - * - * - */ - function set_draft($userid) + /** + * \brief Set draft status + * \param user Object user that modify + * \param int <0 if KO, >0 if OK + */ + function set_draft($user) { + global $conf,$langs; + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0"; + $sql.= " WHERE rowid = ".$this->id; - $sql .= " WHERE rowid = $this->id;"; - - if ($this->db->query($sql) ) + if ($this->db->query($sql)) { return 1; } else { - dolibarr_print_error($this->db); + return -1; } } diff --git a/htdocs/telephonie/facturation/FacturationEmission.class.php b/htdocs/telephonie/facturation/FacturationEmission.class.php index bd926961b02..e6a9e996cea 100644 --- a/htdocs/telephonie/facturation/FacturationEmission.class.php +++ b/htdocs/telephonie/facturation/FacturationEmission.class.php @@ -678,7 +678,7 @@ class FacturationEmission { $y = substr($year, -1); $m = substr("00".$month, -2); - if ( $fac->set_valid($facid, $user, $soc) ) + if ( $fac->set_valid($user, $soc) ) { $valid_ok = 1; } diff --git a/htdocs/telephonie/script/facturation-emission.php b/htdocs/telephonie/script/facturation-emission.php index 354a130f010..a0b10ce6853 100644 --- a/htdocs/telephonie/script/facturation-emission.php +++ b/htdocs/telephonie/script/facturation-emission.php @@ -664,12 +664,12 @@ function facture_contrat($db, $user, $contrat_id, $factel_ids, $datetime, &$fact if (!$error && !$cancel_facture) { - if ($verbose) dolibarr_syslog("Validation de la facture : $facid"); + if ($verbose) dolibarr_syslog("Validation de la facture : $fac->id"); $y = substr($year, -1); $m = substr("00".$month, -2); - if ( $fac->set_valid($facid, $user, $soc) ) + if ( $fac->set_valid($user, $soc) ) { $valid_ok = 1; }