diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4c8cd75d1a608aa3b53b355e885434b458c6b7a0..dcb2ff5d0cd71eb546205ad6b35c2322fbba8182 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -58,7 +58,7 @@ class ActionComm extends CommonObject var $durationp = -1; //var $date; // Date action realise debut (datea) // deprecated //var $dateend; // Date action realise fin (datea2) // deprecated - //var $durationa = -1; // deprecated + //var $durationa = -1; // Duration // deprecated var $priority; var $fulldayevent = 0; // 1=Event on full day var $punctual = 1; @@ -74,40 +74,29 @@ class ActionComm extends CommonObject var $note; var $percentage; - // Properties for links to other tables - var $fk_element; - var $elementtype; - - // Ical + // Properties for links to other objects + var $fk_element; // Id of record + var $elementtype; // Type of record. This if property ->element of object linked to. + + // Ical var $icalname; var $icalcolor; /** - * \brief Constructeur - * \param db Handler d'acces base de donnee + * Constructor + * @param db Database handler */ function ActionComm($db) { $this->db = $db; - /* - $this->societe = new Societe($db); - $this->author = new User($db); - $this->usermod = new User($db); - $this->usertodo = new User($db); - $this->userdone = new User($db); - if (class_exists("Contact")) - { - $this->contact = new Contact($db); - } - */ } /** - * Add an action into database - * @param user auteur de la creation de l'action - * @param notrigger 1 ne declenche pas les triggers, 0 sinon - * @return int id de l'action creee, < 0 if KO + * Add an action/event into database + * @param user Object user making action + * @param notrigger 1 = disable triggers, 0 = enable triggers + * @return int Id of created event, < 0 if KO */ function add($user,$notrigger=0) { @@ -130,6 +119,9 @@ class ActionComm extends CommonObject if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef=$this->datep; if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; if ($this->fk_project < 0) $this->fk_project = 0; + if ($this->elementtype=='facture') $this->elementtype='invoice'; + if ($this->elementtype=='commande') $this->elementtype='order'; + if ($this->elementtype=='contrat') $this->elementtype='contract'; if (! $this->type_id && $this->type_code) { @@ -297,39 +289,16 @@ class ActionComm extends CommonObject $this->societe->id = $obj->fk_soc; $this->contact->id = $obj->fk_contact; $this->fk_project = $obj->fk_project; - + $this->fk_element = $obj->fk_element; $this->elementtype = $obj->elementtype; - - /* - $this->fk_facture = $obj->fk_facture; - if ($this->fk_facture) - { - $this->objet_url = img_object($langs->trans("ShowBill"),'bill').' '.'<a href="'. DOL_URL_ROOT . '/compta/facture.php?facid='.$this->fk_facture.'">'.$langs->trans("Bill").'</a>'; - $this->objet_url_type = 'facture'; - } - - $this->fk_propal = $obj->propalrowid; - if ($this->fk_propal) - { - $this->objet_url = img_object($langs->trans("ShowPropal"),'propal').' '.'<a href="'. DOL_URL_ROOT . '/comm/propal.php?id='.$this->fk_propal.'">'.$langs->trans("Propal").'</a>'; - $this->objet_url_type = 'propal'; - } - - $this->fk_commande = $obj->fk_commande; - if ($this->fk_commande) - { - $this->objet_url = img_object($langs->trans("ShowOrder"),'order').' '.'<a href="'. DOL_URL_ROOT . '/commande/fiche.php?id='.$this->fk_commande.'">'.$langs->trans("Order").'</a>'; - $this->objet_url_type = 'order'; - } - */ } $this->db->free($resql); return 1; } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } } @@ -350,7 +319,7 @@ class ActionComm extends CommonObject } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error=$this->db->lasterror()." sql=".$sql; return -1; } } diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 236d916e81adaf7aa8a92c390a34950a18ee6a44..4180628ce8b1fc7686a4432e94c6f22e0f011f24 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * @@ -27,6 +27,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/compta/tva/class/tva.class.php"); +require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/class/deplacement.class.php"); $langs->load("companies"); $langs->load("users"); @@ -38,8 +39,14 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'deplacement','',''); +/* + * View + */ + llxHeader(); +$tripandexpense_static=new Deplacement($db); + $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -76,12 +83,13 @@ if ($resql) $i = 0; print '<table class="noborder" width="100%">'; print "<tr class=\"liste_titre\">"; - print_liste_field_titre($langs->trans("Ref"),"index.php","d.rowid","","&socid=$socid",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),"index.php","d.type","","&socid=$socid",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),"index.php","d.dated","","&socid=$socid",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","&socid=$socid",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Person"),"index.php","u.name","","&socid=$socid",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("FeesKilometersOrAmout"),"index.php","d.km","","&socid=$socid",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","","&socid=$socid",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"d.type","","&socid=$socid",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"d.dated","","&socid=$socid",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&socid=$socid",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.name","","&socid=$socid",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("FeesKilometersOrAmout"),$_SERVER["PHP_SELF"],"d.km","","&socid=$socid",'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"]); print "</tr>\n"; $var=true; @@ -101,6 +109,8 @@ if ($resql) else print '<td> </td>'; print '<td align="left"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$objp->firstname.' '.$objp->name.'</a></td>'; print '<td align="right">'.$objp->km.'</td>'; + + print '<td align="right">'.$tripandexpense_static->getLibStatut(5).'</td>'; print "</tr>\n"; $i++; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c022daa6438e955aeb73b570f3ca089990729483..da60280be3ee559f196439dc80f032a2ac07374c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1407,7 +1407,7 @@ class CommonObject function callHooks($arraytype) { global $conf; - + if (! is_array($arraytype)) $arraytype=array($arraytype); foreach($conf->hooks_modules as $module => $hooks) @@ -1422,23 +1422,23 @@ class CommonObject $actionfile = 'actions_'.$module.'.class.php'; $daofile = 'dao_'.$module.'.class.php'; $pathroot = ''; - + // Include actions class (controller) dol_include_once($path.$actionfile); - + // Include dataservice class (model) dol_include_once($path.$daofile); - + // Instantiate actions class (controller) $controlclassname = 'Actions'.ucfirst($module); $objModule = new $controlclassname($this->db); $this->hooks[$type][$objModule->module_number] = $objModule; - + // Instantiate dataservice class (model) $modelclassname = 'Dao'.ucfirst($module); $this->hooks[$type][$objModule->module_number]->object = new $modelclassname($this->db); } - } + } } } } @@ -1465,7 +1465,7 @@ class CommonObject // TODO: All functions here must be redesigned and moved as they are not business functions but output functions /** - * + * * Enter description here ... * @param unknown_type $objectid * @param unknown_type $objecttype @@ -1475,7 +1475,7 @@ class CommonObject function getElementUrl($objectid,$objecttype,$withpicto=0,$option='') { global $conf; - + // Parse element/subelement (ex: project_task) $module = $element = $subelement = $objecttype; if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) @@ -1483,31 +1483,35 @@ class CommonObject $module = $element = $regs[1]; $subelement = $regs[2]; } - + $classpath = $element.'/class'; - + // To work with non standard path - if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; } + if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'compta/facture/class'; $module='facture'; $subelement='facture'; } + if ($objecttype == 'commande' || $objecttype == 'order') { $classpath = 'commande/class'; $module='commande'; $subelement='commande'; } if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; } if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; } if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; } if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; } - - $classfile = strtolower($subelement); $classname = ucfirst($subelement); + if ($objecttype == 'contract') { $classpath = 'contrat/class'; $module='contrat'; $subelement='contrat'; } + + print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; + + $classfile = strtolower($subelement); $classname = ucfirst($subelement); if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; } if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; } - + if ($conf->$module->enabled) { dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); - + $object = new $classname($this->db); $ret=$object->fetch($objectid); if ($ret > 0) return $object->getNomUrl($withpicto,$option); } } - + /* This is to show linked object block */ /** diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 4f97a98a6267cdfc43a39de174ca5b383bf814d8..9e11f15fd91dbe30b589e40e4d1bad1c31e90f26 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -523,7 +523,7 @@ if ($_POST['action'] == 'send' && ! $_POST['cancel'] && (empty($conf->global->MA // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($db); - $result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$fichinter,$user,$langs,$conf); + $result=$interface->run_triggers('FICHEINTER_SENTBYMAIL',$fichinter,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers diff --git a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php index 9339e5573ca76dd9ee52f9abaa6926f8042c0a27..a3a4b1b8756861549aad5dffaa19fb0b3628d9d0 100644 --- a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php +++ b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php @@ -133,8 +133,6 @@ class InterfaceActionsAuto $object->sendtoid=0; $object->socid=$object->id; - $object->fk_element=0; - $object->elementtype=''; $ok=1; } elseif ($action == 'CONTRACT_VALIDATE') @@ -149,7 +147,7 @@ class InterfaceActionsAuto $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; - $object->sendtoid=0; + $object->sendtoid=0; $ok=1; } elseif ($action == 'PROPAL_VALIDATE') @@ -180,8 +178,9 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } - $object->sendtoid=0; - $ok=1; + // Parameters $object->sendtoid defined by caller + //$object->sendtoid=0; + $ok=1; } elseif ($action == 'PROPAL_CLOSE_SIGNED') { @@ -239,10 +238,9 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } - $object->sendtoid=0; + // Parameters $object->sendtoid defined by caller + //$object->sendtoid=0; $ok=1; - - // Parameters $object->xxx defined by caller } elseif ($action == 'BILL_VALIDATE') { @@ -274,9 +272,9 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } + // Parameters $object->sendtoid defined by caller + //$object->sendtoid=0; $ok=1; - - // Parameters $object->xxx defined by caller } elseif ($action == 'BILL_PAYED') { @@ -290,7 +288,7 @@ class InterfaceActionsAuto $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; - $object->sendtoid=0; + $object->sendtoid=0; $ok=1; } elseif ($action == 'BILL_CANCEL') @@ -305,7 +303,7 @@ class InterfaceActionsAuto $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; - $object->sendtoid=0; + $object->sendtoid=0; $ok=1; } elseif ($action == 'FICHEINTER_VALIDATE') @@ -320,10 +318,28 @@ class InterfaceActionsAuto $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; - $object->sendtoid=0; + $object->sendtoid=0; + $object->fk_element=0; + $object->elementtype=''; $ok=1; } - elseif ($action == 'SHIPPING_SENTBYMAIL') + elseif ($action == 'FICHEINTER_SENTBYMAIL') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $langs->load("other"); + $langs->load("interventions"); + $langs->load("agenda"); + + $object->actiontypecode='AC_OTH'; + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref); + $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref); + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + + // Parameters $object->sendotid defined by caller + //$object->sendtoid=0; + $ok=1; + } + elseif ($action == 'SHIPPING_SENTBYMAIL') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("other"); @@ -338,9 +354,9 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } + // Parameters $object->sendtoid defined by caller + //$object->sendtoid=0; $ok=1; - - // Parameters $object->xxx defined by caller } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { @@ -353,8 +369,8 @@ class InterfaceActionsAuto $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; - $object->sendtoid=0; - $ok=1; + $object->sendtoid=0; + $ok=1; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { @@ -372,7 +388,8 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } - $object->sendtoid=0; + // Parameters $object->sendotid defined by caller + //$object->sendtoid=0; $ok=1; } elseif ($action == 'BILL_SUPPLIER_VALIDATE') @@ -387,8 +404,8 @@ class InterfaceActionsAuto $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; - $object->sendtoid=0; - $ok=1; + $object->sendtoid=0; + $ok=1; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { @@ -406,7 +423,8 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } - $object->sendtoid=0; + // Parameters $object->sendtoid defined by caller + //$object->sendtoid=0; $ok=1; } elseif ($action == 'BILL_SUPPLIER_PAYED') @@ -456,8 +474,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; $ok=1; } elseif ($action == 'MEMBER_SUBSCRIPTION') @@ -477,8 +493,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; $ok=1; } elseif ($action == 'MEMBER_MODIFY') @@ -500,8 +514,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; $ok=1; } elseif ($action == 'MEMBER_DELETE') @@ -519,8 +531,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->fk_element=0; - $object->elementtype=''; $ok=1; } @@ -556,8 +566,8 @@ class InterfaceActionsAuto //$actioncomm->usertodo = $user; // User affected to action $actioncomm->userdone = $user; // User doing action - $actioncomm->fk_element = $object->fk_element; - $actioncomm->elementtype = $object->elementtype; + $actioncomm->fk_element = $object->id; + $actioncomm->elementtype = $object->element; $ret=$actioncomm->add($user); // User qui saisit l'action if ($ret > 0) diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index a4424c040aaeacd62c206a9f7d8bc59e37382291..64de2c475060068358c47562536b08f2dfc30dc4 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -10,7 +10,7 @@ -- To change type of field: ALTER TABLE llx_table MODIFY name varchar(60); -- --- Fix correupted data +-- Fix corrupted data update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01'; RENAME TABLE llx_c_methode_commande_fournisseur TO llx_c_input_method; @@ -361,3 +361,9 @@ INSERT INTO llx_c_currencies ( code, code_iso, active, label ) VALUES ( 'LH', 'H -- ISV (VAT) Honduras INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (1141,114, '0','0','No ISV',1); INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (1142,114, '12','0','ISV 12%',1); + + +update llx_actioncomm set elementtype='invoice' where elementtype='facture'; +update llx_actioncomm set elementtype='order' where elementtype='commande'; +update llx_actioncomm set elementtype='contract' where elementtype='contrat'; + diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index a3763d60a995566e9f153977f9af223e6ba6cf88..9fa2e1bc089b57399882b1e568bd9987dea4600c 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -315,7 +315,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) { migrate_directories($db,$langs,$conf,'/rss','/externalrss'); - + migrate_actioncomm_element($db,$langs,$conf); // Reload modules @@ -3090,15 +3090,15 @@ function migrate_actioncomm_element($db,$langs,$conf) print '<br>'; print '<b>'.$langs->trans('MigrationActioncommElement')."</b><br>\n"; - + $elements = array( 'propal' => 'propalrowid', - 'commande' => 'fk_commande', - 'facture' => 'fk_facture', - 'contrat' => 'fk_contract', + 'order' => 'fk_commande', + 'invoice' => 'fk_facture', + 'contract' => 'fk_contract', 'order_supplier' => 'fk_supplier_order', 'invoice_supplier' => 'fk_supplier_invoice' ); - + foreach($elements as $type => $field) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm",$field); @@ -3106,24 +3106,25 @@ function migrate_actioncomm_element($db,$langs,$conf) if ($obj) { dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field); - + $db->begin(); - + $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET "; $sql.= "fk_element = ".$field.", elementtype = '".$type."'"; $sql.= " WHERE ".$field." IS NOT NULL"; $sql.= " AND fk_element IS NULL"; $sql.= " AND elementtype IS NULL"; - + $resql = $db->query($sql); if ($resql) { $db->commit(); - + // DDL commands must not be inside a transaction - $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."actioncomm DROP COLUMN ".$field; - $db->query($sqlDrop); - print ". "; + // We will drop at next version because a migrate should be runnable several times if it fails. + //$sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."actioncomm DROP COLUMN ".$field; + //$db->query($sqlDrop); + //print ". "; } else {