/** * Overloading the doActions function : replacing the parent's function with the one below * * @param array() $parameters Hook metadatas (context, etc...) * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) * @param string &$action Current action (if set). Generally create or edit or null * @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @return int < 0 on error, 0 on success, 1 to replace standard code */ function doActions($parameters, &$object, &$action, $hookmanager) { if (in_array('invoicecard', explode(':', $parameters['context']))) { if ($action == 'update_courrier') { global $user, $db, $langs; $object->array_options['options_courrier_envoi'] = time(); $object->insertExtraFields(); dol_include_once('/comm/action/class/actioncomm.class.php'); $a = new ActionComm($db); $a->type_code = 'AC_OTH_AUTO'; $a->label = $langs->trans('ClassifyCourrierEvent', $object->ref); $a->fk_element = $object->id; $a->elementtype = 'facture'; $a->usertodo = $user; $a->userdone = $user; $a->percentage = 100; $a->datep = date('Y-m-d H:i:s'); $a->add($user); setEventMessage('ClassifyCourrierMsg'); } else { if ($action == 'no_courrier') { global $user; $object->array_options['options_courrier_envoi'] = ''; $object->insertExtraFields(); setEventMessage('UnClassifyCourrierMsg'); } } } return 0; }
static function addEvent($fk_facture, $ref = '') { global $db, $langs, $user; dol_include_once('/comm/action/class/actioncomm.class.php'); $a = new ActionComm($db); $a->type_code = 'AC_OTH_AUTO'; $a->label = $langs->trans('BillClassifyDeposed', $ref); $a->fk_element = $fk_facture; $a->elementtype = 'facture'; $a->usertodo = $user; $a->userdone = $user; $a->percentage = 100; $a->datep = date('Y-m-d H:i:s'); $a->add($user); }
/** * Function called when a Dolibarrr business event is done. * All functions "run_trigger" are triggered if file is inside directory htdocs/core/triggers * * Following properties must be filled: * $object->actiontypecode (translation action code: AC_OTH, ...) * $object->actionmsg (note, long text) * $object->actionmsg2 (label, short text) * $object->sendtoid (id of contact) * $object->socid * Optionnal: * $object->fk_element * $object->elementtype * * @param string $action Event action code * @param Object $object Object * @param User $user Object user * @param Translate $langs Object langs * @param conf $conf Object conf * @return int <0 if KO, 0 if no triggered ran, >0 if OK */ function run_trigger($action, $object, $user, $langs, $conf) { $key = 'MAIN_AGENDA_ACTIONAUTO_' . $action; //dol_syslog("xxxxxxxxxxx".$key); if (empty($conf->agenda->enabled)) { return 0; } // Module not active, we do nothing if (empty($conf->global->{$key})) { return 0; } // Log events not enabled for this action $ok = 0; // Actions if ($action == 'COMPANY_CREATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->nom); } $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->nom); if ($object->prefix) { $object->actionmsg .= " (" . $object->prefix . ")"; } //$this->desc.="\n".$langs->transnoentities("Customer").': '.yn($object->client); //$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->socid = $object->id; $ok = 1; } elseif ($action == 'CONTRACT_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("contracts"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'PROPAL_CLOSE_SIGNED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_CLOSE_REFUSED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'ORDER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $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; $ok = 1; } elseif ($action == 'ORDER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $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; $ok = 1; } elseif ($action == 'BILL_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_PAYED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_CANCEL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'FICHEINTER_VALIDATE') { 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; $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; $ok = 1; } 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_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $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"); $langs->load("sendings"); $langs->load("agenda"); $object->actiontypecode = 'AC_SHIP'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $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; $ok = 1; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $langs->load("orders"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendotid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $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; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $langs->load("orders"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_PAYED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_CANCELED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_SUBSCRIPTION') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Amount") . ': ' . $object->last_subscription_amount; $object->actionmsg .= "\n" . $langs->transnoentities("Period") . ': ' . dol_print_date($object->last_subscription_date_start, 'day') . ' - ' . dol_print_date($object->last_subscription_date_end, 'day'); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_MODIFY') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } elseif ($action == 'MEMBER_RESILIATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_DELETE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } // If not found /* else { dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action."); return 0; } */ // Add entry in event table if ($ok) { $now = dol_now(); require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $contactforaction = new Contact($this->db); $societeforaction = new Societe($this->db); if ($object->sendtoid > 0) { $contactforaction->fetch($object->sendtoid); } if ($object->socid > 0) { $societeforaction->fetch($object->socid); } // Insertion action require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); $actioncomm->type_code = $object->actiontypecode; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; $actioncomm->punctual = 1; $actioncomm->percentage = -1; // Not applicable $actioncomm->contact = $contactforaction; $actioncomm->societe = $societeforaction; $actioncomm->author = $user; // User saving action //$actioncomm->usertodo = $user; // User affected to action $actioncomm->userdone = $user; // User doing action $actioncomm->fk_element = $object->id; $actioncomm->elementtype = $object->element; $ret = $actioncomm->add($user); // User qui saisit l'action if ($ret > 0) { return 1; } else { $error = "Failed to insert : " . $actioncomm->error . " "; $this->error = $error; dol_syslog("interface_modAgenda_ActionsAuto.class.php: " . $this->error, LOG_ERR); return -1; } } return 0; }
/** * Create ActionComm * * @param array $authentication Array of authentication information * @param ActionComm $actioncomm $actioncomm * @return array Array result */ function createActionComm($authentication, $actioncomm) { global $db, $conf, $langs; $now = dol_now(); dol_syslog("Function: createActionComm login=" . $authentication['login']); if ($authentication['entity']) { $conf->entity = $authentication['entity']; } // Init and check authentication $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); if (!$error) { $newobject = new ActionComm($db); $newobject->datep = $actioncomm['datep']; $newobject->datef = $actioncomm['datef']; $newobject->type_code = $actioncomm['type_code']; $newobject->societe->id = $actioncomm['socid']; $newobject->fk_project = $actioncomm['projectid']; $newobject->note = $actioncomm['note']; $newobject->contact->id = $actioncomm['contactid']; $newobject->usertodo->id = $actioncomm['usertodo']; $newobject->userdone->id = $actioncomm['userdone']; $newobject->label = $actioncomm['label']; $newobject->percentage = $actioncomm['percentage']; $newobject->priority = $actioncomm['priority']; $newobject->fulldayevent = $actioncomm['fulldayevent']; $newobject->location = $actioncomm['location']; $newobject->fk_element = $actioncomm['fk_element']; $newobject->elementtype = $actioncomm['elementtype']; //Retreive all extrafield for actioncomm // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true); foreach ($extrafields->attribute_label as $key => $label) { $key = 'options_' . $key; $newobject->array_options[$key] = $actioncomm[$key]; } $db->begin(); $result = $newobject->add($fuser); if ($result <= 0) { $error++; } if (!$error) { $db->commit(); $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id); } else { $db->rollback(); $error++; $errorcode = 'KO'; $errorlabel = $newobject->error; } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
function ordonnanceur_link_event(&$Task) { global $db, $user; dol_include_once('/comm/action/class/actioncomm.class.php'); foreach ($Task['tasks'] as &$task) { $t_start = $task['time_estimated_start']; $t_end = $task['time_estimated_end']; $res = $db->query("SELECT id FROM " . MAIN_DB_PREFIX . "actioncomm WHERE elementtype='project_task' AND fk_element=" . (int) $task['id']); $TUserAssigned = array(); foreach ($task['TUser'] as $idContact => $u) { if ($u['selected']) { $TUserAssigned[] = array('id' => $idContact); } } if ($obj = $db->fetch_object($res)) { $a = new ActionComm($db); $a->fetch($obj->id); $a->datep = $t_start; $a->datef = $t_end; $a->durationp = $task['planned_workload'] * 3600; $a->label = $task['ref'] . ' ' . $task['label']; $a->progress = $task['progress']; $a->fk_project = $task['fk_projet']; $a->userassigned = $TUserAssigned; $a->socid = $task['fk_soc']; $a->update($user); // print "update ".$a->id.'<br />'; } else { $a = new ActionComm($db); $a->datep = $t_start; $a->datef = $t_end; $a->userownerid = $user->id; $a->type_code = 'AC_OTH_AUTO'; $a->label = $task['ref'] . ' ' . $task['label']; $a->elementtype = 'project_task'; $a->fk_element = $task['id']; $a->fk_project = $task['fk_projet']; $a->progress = $task['progress']; $a->durationp = $task['planned_workload'] * 3600; $a->userassigned = $TUserAssigned; $a->socid = $task['fk_soc']; $a->add($user); } } }
/** * Function called when a Dolibarrr business event is done. * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) * * Following properties must be filled: * $object->actiontypecode (translation action code: AC_OTH, ...) * $object->actionmsg (note, long text) * $object->actionmsg2 (label, short text) * $object->sendtoid (id of contact) * $object->socid * Optionnal: * $object->fk_element * $object->elementtype * * @param string $action Event action code * @param Object $object Object * @param User $user Object user * @param Translate $langs Object langs * @param conf $conf Object conf * @return int <0 if KO, 0 if no triggered ran, >0 if OK */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { // Module not active, we do nothing if (empty($conf->agenda->enabled)) { return 0; } $key = 'MAIN_AGENDA_ACTIONAUTO_' . $action; // Do not log events not enabled for this action if (empty($conf->global->{$key})) { return 0; } $langs->load("agenda"); // Actions if ($action == 'COMPANY_CREATE') { $langs->load("other"); $langs->load("companies"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name); } $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name); if (!empty($object->prefix)) { $object->actionmsg .= " (" . $object->prefix . ")"; } $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->socid = $object->id; } elseif ($action == 'COMPANY_SENTBYMAIL') { $langs->load("other"); $langs->load("orders"); if (empty($object->actiontypecode)) { $object->actiontypecode = 'AC_OTH_AUTO'; } if (empty($object->actionmsg2)) { dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); } $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'CONTRACT_VALIDATE') { $langs->load("other"); $langs->load("contracts"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); } $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'PROPAL_VALIDATE') { $langs->load("other"); $langs->load("propal"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); } $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'PROPAL_SENTBYMAIL') { $langs->load("other"); $langs->load("propal"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'PROPAL_CLOSE_SIGNED') { $langs->load("other"); $langs->load("propal"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'PROPAL_CLASSIFY_BILLED') { $langs->load("other"); $langs->load("propal"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'PROPAL_CLOSE_REFUSED') { $langs->load("other"); $langs->load("propal"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'ORDER_VALIDATE') { $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); } $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'ORDER_CLOSE') { $langs->load("other"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'ORDER_CLASSIFY_BILLED') { $langs->load("other"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'ORDER_CANCEL') { $langs->load("other"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'ORDER_SENTBYMAIL') { $langs->load("other"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'BILL_VALIDATE') { $langs->load("other"); $langs->load("bills"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'BILL_UNVALIDATE') { $langs->load("other"); $langs->load("bills"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'BILL_SENTBYMAIL') { $langs->load("other"); $langs->load("bills"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'BILL_PAYED') { $langs->load("other"); $langs->load("bills"); // Values for this action can't be defined by caller. $object->actiontypecode = 'AC_OTH_AUTO'; $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'BILL_CANCEL') { $langs->load("other"); $langs->load("bills"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'FICHINTER_CREATE') { $langs->load("other"); $langs->load("interventions"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; } elseif ($action == 'FICHINTER_VALIDATE') { $langs->load("other"); $langs->load("interventions"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; } elseif ($action == 'FICHINTER_MODIFY') { $langs->load("other"); $langs->load("interventions"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; } elseif ($action == 'FICHINTER_SENTBYMAIL') { $langs->load("other"); $langs->load("interventions"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'FICHINTER_CLASSIFY_BILLED') { $langs->load("other"); $langs->load("interventions"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') { $langs->load("other"); $langs->load("interventions"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'FICHINTER_DELETE') { $langs->load("other"); $langs->load("interventions"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; } elseif ($action == 'SHIPPING_VALIDATE') { $langs->load("other"); $langs->load("sendings"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ShippingValidated", $object->newref ? $object->newref : $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingValidated", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'SHIPPING_SENTBYMAIL') { $langs->load("other"); $langs->load("sendings"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { $langs->load("other"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); } $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_APPROVE') { $langs->load("other"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_REFUSE') { $langs->load("other"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { $langs->load("other"); $langs->load("bills"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { $langs->load("other"); $langs->load("bills"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') { $langs->load("other"); $langs->load("bills"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { $langs->load("other"); $langs->load("bills"); $langs->load("orders"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; } elseif ($action == 'BILL_SUPPLIER_PAYED') { $langs->load("other"); $langs->load("bills"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'BILL_SUPPLIER_CANCELED') { $langs->load("other"); $langs->load("bills"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'MEMBER_VALIDATE') { $langs->load("other"); $langs->load("members"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); } $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->newref ? $object->newref : $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'MEMBER_SUBSCRIPTION') { $langs->load("other"); $langs->load("members"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Amount") . ': ' . $object->last_subscription_amount; $object->actionmsg .= "\n" . $langs->transnoentities("Period") . ': ' . dol_print_date($object->last_subscription_date_start, 'day') . ' - ' . dol_print_date($object->last_subscription_date_end, 'day'); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'MEMBER_RESILIATE') { $langs->load("other"); $langs->load("members"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'MEMBER_DELETE') { $langs->load("other"); $langs->load("members"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'PROJECT_CREATE') { $langs->load("other"); $langs->load("projects"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Project") . ': ' . $object->ref; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'TASK_CREATE') { $langs->load("other"); $langs->load("projects"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Task") . ': ' . $object->ref; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'TASK_MODIFY') { $langs->load("other"); $langs->load("projects"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Task") . ': ' . $object->ref; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } elseif ($action == 'TASK_DELETE') { $langs->load("other"); $langs->load("projects"); $object->actiontypecode = 'AC_OTH_AUTO'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Task") . ': ' . $object->ref; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; } else { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' was ran by " . __FILE__ . " but no handler found for this action.", LOG_WARNING); return 0; } dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); // Add entry in event table $now = dol_now(); if (isset($_SESSION['listofnames'])) { $attachs = $_SESSION['listofnames']; if ($attachs && strpos($action, 'SENTBYMAIL')) { $object->actionmsg .= "\n" . $langs->transnoentities("AttachedFiles") . ': ' . $attachs; } } require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $contactforaction = new Contact($this->db); $societeforaction = new Societe($this->db); if ($object->sendtoid > 0) { $contactforaction->fetch($object->sendtoid); } if ($object->socid > 0) { $societeforaction->fetch($object->socid); } // Insertion action require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); $actioncomm->type_code = $object->actiontypecode; // code of parent table llx_c_actioncomm (will be deprecated) $actioncomm->code = 'AC_' . $action; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; $actioncomm->punctual = 1; $actioncomm->percentage = -1; // Not applicable $actioncomm->societe = $societeforaction; $actioncomm->contact = $contactforaction; $actioncomm->socid = $societeforaction->id; $actioncomm->contactid = $contactforaction->id; $actioncomm->authorid = $user->id; // User saving action $actioncomm->userownerid = $user->id; // Owner of action //$actioncomm->userdone = $user; // User doing action (not used anymore) //$actioncomm->userdoneid = $user->id; // User doing action (not used anymore) $actioncomm->fk_element = $object->id; $actioncomm->elementtype = $object->element; $ret = $actioncomm->add($user); // User qui saisit l'action unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse vallue of first action. if ($ret > 0) { $_SESSION['LAST_ACTION_CREATED'] = $ret; return 1; } else { $error = "Failed to insert event : " . $actioncomm->error . " " . join(',', $actioncomm->errors); $this->error = $error; $this->errors = $actioncomm->errors; dol_syslog("interface_modAgenda_ActionsAuto.class.php: " . $this->error, LOG_ERR); return -1; } return 0; }
$mesg='<div class="error">'.$langs->trans("ErrorStatusCantBeZeroIfStarted").'</div>'; } if (! $_POST["apyear"] && ! $_POST["adyear"]) { $error=1; $action = 'create'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'</div>'; } if (! $error) { $db->begin(); // On cree l'action $idaction=$actioncomm->add($user); if ($idaction > 0) { if (! $actioncomm->error) { $db->commit(); if (! empty($backtopage)) { dol_syslog("Back to ".$backtopage); Header("Location: ".$backtopage); } elseif($idaction) { Header("Location: ".DOL_URL_ROOT.'/comm/action/fiche.php?id='.$idaction); }
$a->datef = strtotime('+2 hour', $a->datep); $a->userownerid = GETPOST('fk_user') ? GETPOST('fk_user') : $user->id; $a->type_code = GETPOST('type_code') ? GETPOST('type_code') : 'AC_OTH'; $a->socid = GETPOST('fk_soc'); $a->contactid = GETPOST('fk_contact'); $a->fk_project = GETPOST('fk_project', 'int'); $a->percentage = -1; // Non applicable $moreParams = GETPOST('moreParams'); $moreParams = explode(',', $moreParams); $TParam = array(); foreach ($moreParams as $param) { $a->_[$param] = GETPOST($param); } //var_dump($conf->global->FULLCALENDAR_SHOW_THIS_HOURS,GETPOST('date'),$a);exit; $res = $a->add($user); $a->update($user); print $res; break; } function _events($date_start, $date_end) { global $db, $conf, $langs, $user, $hookmanager; $hookmanager->initHooks(array('agenda')); $pid = GETPOST("projectid", "int", 3); $status = GETPOST("status"); $type = GETPOST("type"); $state_id = GETPOST('state_id'); $maxprint = GETPOST("maxprint") ? GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW; //First try with GETPOST(array) (I don't know when it can be an array but why not) $actioncode = GETPOST("actioncode", "array", 3) ? GETPOST("actioncode", "array", 3) : (GETPOST("actioncode") == '0' ? '0' : '');