From c1d15a9572f35b9e05068af1ae3332fd8e7afc1a Mon Sep 17 00:00:00 2001 From: Stephen L <lrq3000@gmail.com> Date: Tue, 14 Aug 2012 15:50:45 +0200 Subject: [PATCH] Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches) Signed-off-by: Stephen L. <lrq3000@gmail.com> --- htdocs/comm/action/fiche.php | 13 +++++++ .../deplacement/class/deplacement.class.php | 10 +++++ htdocs/compta/deplacement/fiche.php | 17 ++++++++ htdocs/compta/dons/class/don.class.php | 13 ++++++- htdocs/compta/dons/fiche.php | 17 ++++++++ htdocs/compta/tva/class/tva.class.php | 16 ++++++-- htdocs/compta/tva/fiche.php | 14 +++++++ htdocs/contact/fiche.php | 12 ++++++ htdocs/contrat/fiche.php | 13 +++++++ htdocs/core/tpl/freeproductline_edit.tpl.php | 4 +- .../tpl/predefinedproductline_edit.tpl.php | 3 +- htdocs/expedition/fiche.php | 39 ++++++++++++------- htdocs/fichinter/class/fichinter.class.php | 5 ++- htdocs/fichinter/fiche.php | 13 +++++++ .../class/fournisseur.commande.class.php | 30 +++++++++++++- .../fourn/class/fournisseur.facture.class.php | 32 +++++++++++++-- htdocs/fourn/commande/fiche.php | 16 ++++++++ htdocs/fourn/facture/fiche.php | 33 +++++++++++++--- htdocs/projet/fiche.php | 17 ++++++++ htdocs/projet/tasks.php | 9 +++++ htdocs/projet/tasks/task.php | 13 +++++++ 21 files changed, 305 insertions(+), 34 deletions(-) diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index b2cb670324c..fc671b76436 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -62,6 +62,11 @@ $actioncomm = new ActionComm($db); $contact = new Contact($db); //var_dump($_POST); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('actioncard')); + /* * Action creation de l'action @@ -566,6 +571,10 @@ if ($action == 'create') $doleditor->Create(); print '</td></tr>'; + // Other attributes + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$actioncomm,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '<center><br>'; @@ -944,6 +953,10 @@ if ($id) print dol_htmlentitiesbr($act->note); print '</td></tr>'; + // Other attributes + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook + print '</table>'; } diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index f6639252735..0d3d6e09b31 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -122,6 +122,16 @@ class Deplacement extends CommonObject if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement"); + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('DEPLACEMENT_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + $result=$this->update($user); if ($result > 0) { diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 4a8168e398f..2c99bb9078c 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -48,6 +48,11 @@ $mesg = ''; $object = new Deplacement($db); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('tripsandexpensescard')); + /* * Actions @@ -317,6 +322,10 @@ if ($action == 'create') print '</td></tr>'; } + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '<br><center><input class="button" type="submit" value="'.$langs->trans("Save").'"> '; @@ -408,6 +417,10 @@ else if ($id) print "</td></tr>"; } + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '<br><center><input type="submit" class="button" value="'.$langs->trans("Save").'"> '; @@ -508,6 +521,10 @@ else if ($id) // Statut print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>'; + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print "</table><br>"; // Notes diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index 5c5a9a10439..4efe9a39e02 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -352,7 +352,18 @@ class Don extends CommonObject $result = $this->db->query($sql); if ($result) { - return $this->db->last_insert_id(MAIN_DB_PREFIX."don"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don"); + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('DON_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + + return $this->id; } else { diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index 422a20ae1a7..e779308164e 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -49,6 +49,11 @@ $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOS // Security check $result = restrictedArea($user, 'don', $id); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('doncard')); + /* * Actions @@ -321,6 +326,10 @@ if ($action == 'create') print "</td></tr>\n"; } + // Other attributes + $parameters=array('colspan' => ' colspan="1"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$don,$action); // Note that $action and $object may have been modified by hook + print "</table>\n"; print '<br><center><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>'; print "</form>\n"; @@ -410,6 +419,10 @@ if (! empty($id) && $action == 'edit') print '</td></tr>'; } + // Other attributes + $parameters=array('colspan' => ' colspan="1"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$don,$action); // Note that $action and $object may have been modified by hook + print "</table>\n"; print '<br><center><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>'; @@ -494,6 +507,10 @@ if (! empty($id) && $action != 'edit') print "<tr>".'<td>'.$langs->trans("Project").'</td><td>'.$don->projet.'</td></tr>'; } + // Other attributes + $parameters=array('colspan' => ' colspan="1"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$don,$action); // Note that $action and $object may have been modified by hook + print "</table>\n"; print "</form>\n"; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 6dd3183e02d..d320e394d27 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -60,6 +60,8 @@ class Tva extends CommonObject function __construct($db) { $this->db = $db; + $this->element = 'tva'; + $this->table_element = 'tva'; return 1; } @@ -122,7 +124,7 @@ class Tva extends CommonObject // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); - $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('TVA_CREATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -189,7 +191,7 @@ class Tva extends CommonObject // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); - $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + $result=$interface->run_triggers('TVA_MODIFY',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers } @@ -289,7 +291,7 @@ class Tva extends CommonObject // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); - $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('TVA_DELETE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -512,6 +514,14 @@ class Tva extends CommonObject if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO devrait s'appeler paiementtva + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('TVA_ADDPAYMENT',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + if ($this->id > 0) { $ok=1; diff --git a/htdocs/compta/tva/fiche.php b/htdocs/compta/tva/fiche.php index f2667f697e1..9837fabe418 100644 --- a/htdocs/compta/tva/fiche.php +++ b/htdocs/compta/tva/fiche.php @@ -40,6 +40,11 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('taxvatcard')); + /** * Action ajout paiement tva @@ -178,6 +183,11 @@ if ($_GET["action"] == 'create') print "</td>\n"; print "</tr>"; } + + // Other attributes + $parameters=array('colspan' => ' colspan="1"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print "<br>"; @@ -242,6 +252,10 @@ if ($id) } } + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$vatpayment,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '</div>'; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 7f9fe21e9a1..f42414a980b 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -492,6 +492,10 @@ else } print '</tr>'; + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print "</table><br><br>"; @@ -673,6 +677,10 @@ else else print $langs->trans("NoDolibarrAccess"); print '</td></tr>'; + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table><br>'; print '<center>'; @@ -858,6 +866,10 @@ else else print $langs->trans("NoDolibarrAccess"); print '</td></tr>'; + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print "</table>"; print "</div>"; diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index a1367ebae61..b098a8d093a 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -58,6 +58,11 @@ $result=restrictedArea($user,'contrat',$id); $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('contractcard')); + $object = new Contrat($db); @@ -633,6 +638,10 @@ if ($action == 'create') print '</textarea></td></tr>'; } + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print "</table>\n"; print '<br><center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>'; @@ -779,6 +788,10 @@ else print "</td></tr>"; } + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print "</table>"; if (! empty($object->brouillon) && $user->rights->contrat->creer) diff --git a/htdocs/core/tpl/freeproductline_edit.tpl.php b/htdocs/core/tpl/freeproductline_edit.tpl.php index e3df369e392..91721cd6d3d 100644 --- a/htdocs/core/tpl/freeproductline_edit.tpl.php +++ b/htdocs/core/tpl/freeproductline_edit.tpl.php @@ -41,7 +41,7 @@ <?php if (is_object($hookmanager)) { - $parameters=array('fk_parent_line'=>$line->fk_parent_line); + $parameters=array('line'=>$line,'fk_parent_line'=>$line->fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); echo $hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action); } @@ -75,7 +75,7 @@ </td> <?php -if (! empty($conf->margin->enabled)) { +if (! empty($conf->margin->enabled)) { ?> <td align="right"><input type="text" size="5" name="buying_price" value="<?php echo price($line->pa_ht,0,'',0); ?>"></td> <?php diff --git a/htdocs/core/tpl/predefinedproductline_edit.tpl.php b/htdocs/core/tpl/predefinedproductline_edit.tpl.php index eedf59efb6b..533185b156b 100644 --- a/htdocs/core/tpl/predefinedproductline_edit.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_edit.tpl.php @@ -51,7 +51,7 @@ if (is_object($hookmanager)) { $fk_parent_line = ($_POST["fk_parent_line"] ? $_POST["fk_parent_line"] : $line->fk_parent_line); - $parameters=array('fk_parent_line'=>$fk_parent_line); + $parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); echo $hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action); } @@ -162,4 +162,3 @@ $(document).ready(function() { </script> <?php } ?> <!-- END PHP TEMPLATE predefinedproductline_edit.tpl.php --> - diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 9fe0c57fb6c..c6fbc729765 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -57,6 +57,11 @@ $ref=GETPOST('ref','alpha'); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,$origin,$origin_id); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('expeditioncard')); + $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); @@ -317,21 +322,21 @@ else if ($action == 'builddoc') // En get ou en post } } -// Delete file in doc form -elseif ($action == 'remove_file') -{ +// Delete file in doc form +elseif ($action == 'remove_file') +{ require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - $object = new Expedition($db); - if ($object->fetch($id)) - { - $object->fetch_thirdparty(); - $upload_dir = $conf->expedition->dir_output . "/sending"; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - } + $object = new Expedition($db); + if ($object->fetch($id)) + { + $object->fetch_thirdparty(); + $upload_dir = $conf->expedition->dir_output . "/sending"; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + } } /* @@ -663,6 +668,10 @@ if ($action == 'create') print '<input name="tracking_number" size="20" value="'.GETPOST('tracking_number','alpha').'">'; print "</td></tr>\n"; + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook + print "</table>"; /* @@ -1123,6 +1132,10 @@ else print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number); print '</td></tr>'; + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print "</table>\n"; /* diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index f8c801e237c..d2287050cc4 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -156,6 +156,9 @@ class Fichinter extends CommonObject $result=$this->db->query($sql); if ($result) { + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); + $this->db->commit(); + // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); @@ -165,8 +168,6 @@ class Fichinter extends CommonObject } // Fin appel triggers - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); - $this->db->commit(); return $this->id; } else diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 559d89da0ae..8c7eb21e1f8 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -59,6 +59,11 @@ $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($co if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('interventioncard')); + $object = new Fichinter($db); @@ -810,6 +815,10 @@ if ($action == 'create') print '</td></tr>'; } + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '<center><br>'; @@ -940,6 +949,10 @@ else if ($id > 0 || ! empty($ref)) // Statut print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>'; + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print "</table><br>"; if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index af36be18a44..e7989d21438 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1011,7 +1011,7 @@ class CommandeFournisseur extends CommonOrder * @param int $info_bits More information * @return int <=0 if KO, >0 if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $type=0, $info_bits=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $type=0, $info_bits=0, $notrigger=false) { global $langs,$mysoc; @@ -1139,6 +1139,19 @@ class CommandeFournisseur extends CommonOrder //print $sql; if ($resql) { + $this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande_fournisseurdet'); + + if (! $notrigger) + { + global $conf, $langs, $user; + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('LINEORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } + $this->update_price(); $this->db->commit(); @@ -1584,7 +1597,7 @@ class CommandeFournisseur extends CommonOrder * @param int $type Type of line (0=product, 1=service) * @return int < 0 if error, > 0 if ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false) { dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type"); include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); @@ -1660,6 +1673,19 @@ class CommandeFournisseur extends CommonOrder $result = $this->db->query($sql); if ($result > 0) { + $this->rowid = $rowid; + + if (! $notrigger) + { + global $conf, $langs, $user; + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('LINEORDER_SUPPLIER_UPDATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } + // Mise a jour info denormalisees au niveau facture $this->update_price(); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c85e8e81dc8..a25d9c54426 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -976,7 +976,7 @@ class FactureFournisseur extends CommonInvoice * @param int $rang Position of line * @return int >0 if OK, <0 if KO */ - function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1) + function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false) { dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type", LOG_DEBUG); include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); @@ -1013,9 +1013,22 @@ class FactureFournisseur extends CommonInvoice { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); - $result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent); + $result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true); if ($result > 0) { + $this->rowid = $idligne; + + if (! $notrigger) + { + global $conf, $langs, $user; + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('LINEBILL_SUPPLIER_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } + $this->db->commit(); return 1; } @@ -1051,7 +1064,7 @@ class FactureFournisseur extends CommonInvoice * @param double $remise_percent Pourcentage de remise de la ligne * @return int <0 if KO, >0 if OK */ - function updateline($id, $label, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0) + function updateline($id, $label, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false) { dol_syslog(get_class($this)."::updateline $id,$label,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG); include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); @@ -1117,6 +1130,19 @@ class FactureFournisseur extends CommonInvoice $resql=$this->db->query($sql); if ($resql) { + $this->rowid = $id; + + if (! $notrigger) + { + global $conf, $langs, $user; + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('LINEBILL_SUPPLIER_UPDATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + } + // Update total price into invoice record $result=$this->update_price(); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 613d7272a75..03b54bcdc67 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1186,6 +1186,10 @@ if ($id > 0 || ! empty($ref)) print '</tr>'; } + // Other attributes + $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // Ligne de 3 colonnes print '<tr><td>'.$langs->trans("AmountHT").'</td>'; print '<td align="right"><b>'.price($object->total_ht).'</b></td>'; @@ -1382,6 +1386,12 @@ if ($id > 0 || ! empty($ref)) if ($conf->product->enabled && $conf->service->enabled) print '<br>'; } + if (is_object($hookmanager)) + { + $parameters=array('fk_parent_line'=>$line->fk_parent_line, 'line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i); + echo $hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action); + } + // Description - Editor wysiwyg require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); $nbrows=ROWS_2; @@ -1438,6 +1448,12 @@ if ($id > 0 || ! empty($ref)) if ($forceall || ($conf->product->enabled && $conf->service->enabled) || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>'; + if (is_object($hookmanager)) + { + $parameters=array(); + echo $hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + } + $nbrows=ROWS_2; if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; $doleditor = new DolEditor('dp_desc', GETPOST('dp_desc'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, $nbrows, 70); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 0f88a16d7f2..eb69f8b5652 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -473,7 +473,7 @@ elseif ($action == 'addline') // cas special pour lequel on a les meme reference que le fournisseur // $label = '['.$product->ref.'] - '. $product->libelle; $label = $product->description; - $label.= $product->description && $_POST['np_desc'] ? "\n" : ""; + $label.= $product->description && $_POST['np_desc'] ? "\n" : ""; $label.= $_POST['np_desc']; $tvatx=get_default_tva($object->thirdparty, $mysoc, $product->id, $_POST['idprodfournprice']); @@ -1169,6 +1169,11 @@ if ($action == 'create') } } } + + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // Bouton "Create Draft" print "</table>\n"; @@ -1510,6 +1515,10 @@ else print '</tr>'; } + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table><br>'; if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) @@ -1602,6 +1611,12 @@ else || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>'; } + if (is_object($hookmanager)) + { + $parameters=array('fk_parent_line'=>$line->fk_parent_line, 'line'=>$object->lines[$i],'var'=>$var,'num'=>$num,'i'=>$i); + echo $hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action); + } + // Description - Editor wysiwyg require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); $nbrows=ROWS_2; @@ -1732,6 +1747,12 @@ else if ($forceall || ($conf->product->enabled && $conf->service->enabled) || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>'; + if (is_object($hookmanager)) + { + $parameters=array(); + echo $hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + } + // Editor wysiwyg require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); $nbrows=ROWS_2; @@ -1786,7 +1807,7 @@ else print '<td colspan="4">'; $form->select_produits_fournisseurs($object->socid,'','idprodfournprice'); - if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print '<br>'; + if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print '<br>'; if (is_object($hookmanager)) { @@ -1794,9 +1815,9 @@ else echo $hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action); } - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor = new DolEditor('np_desc', GETPOST('np_desc'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, $nbrows, 70); + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $doleditor = new DolEditor('np_desc', GETPOST('np_desc'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, $nbrows, 70); $doleditor->Create(); print '</td>'; @@ -2014,4 +2035,4 @@ else // End of page llxFooter(); $db->close(); -?> +?> \ No newline at end of file diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index 70cdceffff1..bb3376c6314 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -49,6 +49,11 @@ $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $id); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('projectcard')); + $object = new Project($db); $object->fetch($id,$ref); if ($object->id > 0) @@ -396,6 +401,10 @@ if ($action == 'create' && $user->rights->projet->creer) print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$_POST["description"].'</textarea>'; print '</td></tr>'; + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '<br><center>'; @@ -527,6 +536,10 @@ else print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$object->description.'</textarea>'; print '</td></tr>'; + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '<div align="center"><br>'; @@ -585,6 +598,10 @@ else print nl2br($object->description); print '</td></tr>'; + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index ec9144d3f5f..4aef7365650 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -54,6 +54,11 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $result = restrictedArea($user, 'projet', $id); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('projecttaskcard')); + $progress=GETPOST('progress', 'int'); $label=GETPOST('label', 'alpha'); $description=GETPOST('description'); @@ -277,6 +282,10 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$description.'</textarea>'; print '</td></tr>'; + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '<div align="center"><br>'; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 179f78098a7..49499f25fd6 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -41,6 +41,11 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; if (! $user->rights->projet->lire) accessforbidden(); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('projecttaskcard')); + $object = new Task($db); $projectstatic = new Project($db); @@ -281,6 +286,10 @@ if ($id > 0 || ! empty($ref)) print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$object->description.'</textarea>'; print '</td></tr>'; + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; print '<center><br>'; @@ -357,6 +366,10 @@ if ($id > 0 || ! empty($ref)) print nl2br($object->description); print '</td></tr>'; + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print '</table>'; } -- GitLab