/** * 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); }
/** * Write content of pages * * @param PDF $pdf Object pdf * @param Translate $outputlangs Object langs * @return int 1 */ function _pages(&$pdf, $outputlangs) { global $conf; $height = 3; // height for text separation $pagenb = 1; $y = $this->_pagehead($pdf, $outputlangs, $pagenb); $y++; $pdf->SetFont('', '', 8); $sql = "SELECT s.nom as thirdparty, s.rowid as socid, s.client,"; $sql .= " a.id, a.datep as dp, a.datep2 as dp2,"; $sql .= " a.fk_contact, a.note, a.percent as percent, a.label, a.fk_project,"; $sql .= " c.code, c.libelle,"; $sql .= " u.login"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_actioncomm as c, " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE c.id=a.fk_action AND a.fk_user_author = u.rowid"; $sql .= " AND a.datep BETWEEN '" . $this->db->idate(dol_get_first_day($this->year, $this->month, false)) . "'"; $sql .= " AND '" . $this->db->idate(dol_get_last_day($this->year, $this->month, false)) . "'"; $sql .= " AND a.entity = " . $conf->entity; $sql .= " ORDER BY a.datep DESC"; $eventstatic = new ActionComm($this->db); $projectstatic = new Project($this->db); dol_syslog(get_class($this) . "::_page", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; $y0 = $y1 = $y2 = $y3 = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $eventstatic->id = $obj->id; $eventstatic->percentage = $obj->percentage; $eventstatic->fulldayevent = $obj->fulldayevent; $eventstatic->punctual = $obj->punctual; $y = max($y, $pdf->GetY(), $y0, $y1, $y2, $y3); // Calculate height of text $text = ''; if (!preg_match('/^' . preg_quote($obj->label) . '/', $obj->note)) { $text = $obj->label . "\n"; } $text .= $obj->note; $text = dol_trunc(dol_htmlentitiesbr_decode($text), 150); // Add status to text $text .= "\n"; $status = dol_htmlentitiesbr_decode($eventstatic->getLibStatut(1, 1)); $text .= $status; if ($obj->fk_project > 0) { $projectstatic->fetch($obj->fk_project); $text .= ($status ? ' - ' : '') . $outputlangs->transnoentitiesnoconv("Project") . ": " . dol_htmlentitiesbr_decode($projectstatic->getNomUrl(0, 'nolink')); } //print 'd'.$text; exit; $nboflines = dol_nboflines($text); $heightlinemax = max(2 * $height, $nboflines * $height); // Check if there is enough space to print record if (1 + $y + $heightlinemax >= $this->page_hauteur - $this->marge_haute) { // We need to break page $pagenb++; $y = $this->_pagehead($pdf, $outputlangs, $pagenb); $y++; $pdf->SetFont('', '', 8); } $y++; // Date $pdf->SetXY($this->marge_gauche, $y); $pdf->MultiCell(22, $height, dol_print_date($this->db->jdate($obj->dp), "day") . "\n" . dol_print_date($this->db->jdate($obj->dp), "hour"), 0, 'L', 0); $y0 = $pdf->GetY(); // Third party $pdf->SetXY(26, $y); $pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($obj->thirdparty), 32), 0, 'L', 0); $y1 = $pdf->GetY(); // Action code $code = $obj->code; if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($code == 'AC_OTH') { $code = 'AC_MANUAL'; } if ($code == 'AC_OTH_AUTO') { $code = 'AC_AUTO'; } } $pdf->SetXY(60, $y); $pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Action" . $code)), 32), 0, 'L', 0); $y2 = $pdf->GetY(); // Description of event $pdf->SetXY(106, $y); $pdf->MultiCell(94, $height, $outputlangs->convToOutputCharset($text), 0, 'L', 0); $y3 = $pdf->GetY(); $i++; } } return 1; }
//fk_user_action //print $sql; dol_syslog("comm/action/index.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); // Discard auto action if option is on if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') { $i++; continue; } // Create a new object action $event = new ActionComm($db); $event->id = $obj->id; $event->datep = $db->jdate($obj->datep); // datep and datef are GMT date $event->datef = $db->jdate($obj->datep2); $event->type_code = $obj->code; $event->type_color = $obj->color; //$event->libelle=$obj->label; // deprecated $event->label = $obj->label; $event->percentage = $obj->percent; //$event->author->id=$obj->fk_user_author; // user id of creator $event->authorid = $obj->fk_user_author; // user id of creator $event->userownerid = $obj->fk_user_action; // user id of owner $event->fetch_userassigned();
if (GETPOST("viewlist")) { $param=''; foreach($_POST as $key => $val) { if ($key=='token') continue; $param.='&'.$key.'='.urlencode($val); } //print $param; header("Location: ".DOL_URL_ROOT.'/comm/action/listactions.php?'.$param); exit; } if ($action=='delete_action') { $event = new ActionComm($db); $event->fetch($actionid); $result=$event->delete(); } /* * View */ $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); $form=new Form($db); $companystatic=new Societe($db);
/** * Show last actions array * * @param int $max Max nb of records * @return void */ function show_array_last_actions_done($max = 5) { global $langs, $conf, $user, $db, $bc, $socid; $now = dol_now(); $sql = "SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label,"; $sql .= " c.code, c.libelle,"; $sql .= " s.rowid, s.nom as sname, s.client"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_actioncomm as c LEFT JOIN "; $sql .= " " . MAIN_DB_PREFIX . "actioncomm as a ON c.id = a.fk_action "; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE a.entity = " . $conf->entity; $sql .= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '" . $db->idate($now) . "'))"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $socid; } $sql .= " ORDER BY a.datep2 DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td colspan="2">' . $langs->trans("LastDoneTasks", $max) . '</td>'; print '<td colspan="2" align="right"><a href="' . DOL_URL_ROOT . '/comm/action/listactions.php?status=done">' . $langs->trans("FullList") . '</a>'; print '</tr>'; $var = true; $i = 0; $staticaction = new ActionComm($db); $customerstatic = new Societe($db); while ($i < $num) { $obj = $db->fetch_object($resql); $var = !$var; print '<tr ' . $bc[$var] . '>'; $staticaction->type_code = $obj->code; $staticaction->libelle = $obj->label; $staticaction->id = $obj->id; print '<td>' . $staticaction->getNomUrl(1, 34) . '</td>'; //print '<td>'.dol_trunc($obj->label,24).'</td>'; print '<td>'; if ($obj->rowid > 0) { $customerstatic->id = $obj->rowid; $customerstatic->name = $obj->sname; $customerstatic->client = $obj->client; print $customerstatic->getNomUrl(1, '', 24); } print '</td>'; // Date print '<td width="100" align="right">' . dol_print_date($db->jdate($obj->da2), 'day'); print "</td>"; // Statut print "<td align=\"right\" width=\"14\">" . $staticaction->LibStatut($obj->percent, 3) . "</td>\n"; print "</tr>\n"; $i++; } // TODO Ajouter rappel pour "il y a des contrats a mettre en service" // TODO Ajouter rappel pour "il y a des contrats qui arrivent a expiration" print "</table><br>"; $db->free($resql); } else { dol_print_error($db); } }
$langs->load("other"); $langs->load("bills"); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check $socid = GETPOST('socid', 'int'); if ($user->societe_id) { $socid = $user->societe_id; } if ($user->societe_id > 0) { unset($_GET["action"]); $action = ''; } $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); $object = new ActionComm($db); if ($id > 0) { $ret = $object->fetch($id); $object->fetch_thirdparty(); } // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) {
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; }
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); } /* * View */ $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); if ($objectid > 0) { $act = new ActionComm($db); if ($act->fetch($objectid)) { $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid); $company=new Societe($db); $company->fetch($act->societe->id); $act->societe=$company; $author=new User($db); $author->fetch($act->author->id); $act->author=$author; $contact=new Contact($db); $contact->fetch($act->contact->id); $act->contact=$contact;
print '<th class="liste_titre"colspan="2">' . $langs->trans("DolibarrWorkBoard") . '</th>'; print '<th class="liste_titre"align="right">' . $langs->trans("Number") . '</th>'; print '<th class="liste_titre"align="right">' . $langs->trans("Late") . '</th>'; print '<th class="liste_titre"> </th>'; print '<th class="liste_titre"width="20"> </th>'; if ($showweather) { print '<th class="liste_titre hideonsmartphone" width="80"> </th>'; } print '</tr>'; // // Do not include sections without management permission // // Number of actions to do (late) if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) { include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $board = new ActionComm($db); $board->load_board($user); $board->warning_delay = $conf->actions->warning_delay / 60 / 60 / 24; $board->label = $langs->trans("ActionsToDo"); $board->url = DOL_URL_ROOT . '/comm/action/listactions.php?status=todo&usertodo=-1&mainmenu=agenda'; $board->img = img_object($langs->trans("Actions"), "action"); $rowspan++; $dashboardlines[] = $board; } // Number of customer orders a deal if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $board = new Commande($db); $board->load_board($user); $board->warning_delay = $conf->commande->client->warning_delay / 60 / 60 / 24; $board->label = $langs->trans("OrdersToProcess");
print "</form>"; } // View or edit if ($id) { if ($error) { print '<div class="error">'.$error.'</div><br>'; } if ($mesg) { print $mesg.'<br>'; } $act = new ActionComm($db); $result=$act->fetch($id); if ($result < 0) { dol_print_error($db,$act->error); exit; } $societe = new Societe($db); if ($act->societe->id) { $result=$societe->fetch($act->societe->id); } $act->societe = $societe; if ($act->author->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($act->author->id); $act->author=$tmpuser; }
/** * Show list of actions for element * * @param Object $object Object * @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter' * @param int $socid socid of user * @return int <0 if KO, >=0 if OK */ function showactions($object, $typeelement, $socid = 0) { global $langs, $conf, $user; global $bc; require_once DOL_DOCUMENT_ROOT . "/comm/action/class/actioncomm.class.php"; $actioncomm = new ActionComm($this->db); $actioncomm->getActions($socid, $object->id, $typeelement); $num = count($actioncomm->actions); if ($num) { if ($typeelement == 'invoice') { $title = $langs->trans('ActionsOnBill'); } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') { $title = $langs->trans('ActionsOnBill'); } elseif ($typeelement == 'propal') { $title = $langs->trans('ActionsOnPropal'); } elseif ($typeelement == 'order') { $title = $langs->trans('ActionsOnOrder'); } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') { $title = $langs->trans('ActionsOnOrder'); } elseif ($typeelement == 'project') { $title = $langs->trans('ActionsOnProject'); } elseif ($typeelement == 'shipping') { $title = $langs->trans('ActionsOnShipping'); } elseif ($typeelement == 'fichinter') { $title = $langs->trans('ActionsOnFicheInter'); } else { $title = $langs->trans("Actions"); } print_titre($title); $total = 0; $var = true; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><th class="liste_titre">' . $langs->trans('Ref') . '</th><th class="liste_titre">' . $langs->trans('Date') . '</th><th class="liste_titre">' . $langs->trans('Action') . '</th><th class="liste_titre">' . $langs->trans('By') . '</th></tr>'; print "\n"; foreach ($actioncomm->actions as $action) { $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>' . $action->getNomUrl(1) . '</td>'; print '<td>' . dol_print_date($action->datep, 'day') . '</td>'; print '<td title="' . dol_escape_htmltag($action->label) . '">' . dol_trunc($action->label, 32) . '</td>'; $userstatic = new User($this->db); $userstatic->id = $action->author->id; $userstatic->firstname = $action->author->firstname; $userstatic->lastname = $action->author->lastname; print '<td>' . $userstatic->getNomUrl(1) . '</td>'; print '</tr>'; } print '</table>'; } return $num; }
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' : ''); //If empty then try GETPOST(alpha) (this one works with comm/action/index.php if (empty($actioncode)) { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : ''); if (!empty($actioncode)) { $actioncode = array($actioncode); } } if (empty($actioncode)) { $actioncode = array(); } $filter = GETPOST("filter", '', 3); $filtert = GETPOST("usertodo", "int", 3) ? GETPOST("usertodo", "int", 3) : GETPOST("filtert", "int", 3); $usergroup = GETPOST("usergroup", "int", 3); $showbirthday = empty($conf->use_javascript_ajax) ? GETPOST("showbirthday", "int") : 1; if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { $filtert = $user->id; } $socid = GETPOST("socid", "int"); $t_start = strtotime($date_start); $t_end = strtotime($date_end); $now = dol_now(); $sql = 'SELECT '; if ($usergroup > 0) { $sql .= " DISTINCT"; } $sql .= ' a.id, a.label,'; $sql .= ' a.datep,'; $sql .= ' a.datep2,'; $sql .= ' a.percent,'; $sql .= ' a.fk_user_author,a.fk_user_action,'; $sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql .= ' a.fk_soc, a.fk_contact,u.color,a.note,'; $sql .= ' ca.code as type_code, ca.libelle as type_label'; $sql .= ' FROM ' . MAIN_DB_PREFIX . "actioncomm as a"; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_actioncomm as ca ON (a.fk_action = ca.id)'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user u ON (a.fk_user_action=u.rowid )'; if (!empty($conf->global->FULLCALENDAR_FILTER_ON_STATE) && !empty($state_id)) { $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe s ON (s.rowid = a.fk_soc)'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople sp ON (sp.rowid = a.fk_contact)'; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "actioncomm_resources as ar ON (ar.fk_actioncomm = a.id)"; } if ($usergroup > 0) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; } $sql .= ' WHERE 1=1'; $sql .= ' AND a.entity IN (' . getEntity('agenda', 1) . ')'; if ($actioncode) { $sql .= " AND ca.code IN ('" . implode("','", $actioncode) . "')"; } if ($conf->global->DONT_SHOW_AUTO_EVENT && strpos(implode(',', $actioncode), 'AC_OTH_AUTO') == false) { $sql .= " AND ca.code != 'AC_OTH_AUTO'"; } if ($pid) { $sql .= " AND a.fk_project=" . $db->escape($pid); } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = "******")"; } if ($socid > 0) { $sql .= ' AND a.fk_soc = ' . $socid; } if (!empty($conf->global->FULLCALENDAR_FILTER_ON_STATE) && !empty($state_id)) { $sql .= ' AND (s.fk_departement = ' . $state_id . ' OR sp.fk_departement = ' . $state_id . ')'; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { $sql .= " AND ar.element_type='user'"; } $sql .= " AND\n\t\t\t(\n\t\t\t\t(a.datep2>='" . $db->idate($t_start - 60 * 60 * 24 * 7) . "' AND datep<='" . $db->idate($t_end + 60 * 60 * 24 * 10) . "')\n\t\t\t\tOR\n\t\t\t \t(a.datep BETWEEN '" . $db->idate($t_start - 60 * 60 * 24 * 7) . "' AND '" . $db->idate($t_end + 60 * 60 * 24 * 10) . "')\n\t\t\t) "; if ($type) { $sql .= " AND ca.id = " . $type; } if ($status == '0') { $sql .= " AND a.percent = 0"; } if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '" . $db->idate($now) . "'))"; } if ($status == 'todo') { $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '" . $db->idate($now) . "'))"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { $sql .= " AND ("; if ($filtert > 0) { $sql .= "ar.fk_element = " . $filtert; } if ($usergroup > 0) { $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup; } $sql .= ")"; } // Sort on date $sql .= ' ORDER BY datep'; $TEvent = array(); if (isset($_REQUEST['DEBUG'])) { print $sql; } $res = $db->query($sql); //var_dump($db); $TSociete = array(); $TContact = array(); $TUser = array(); $TProject = array(); $TEventObject = array(); while ($obj = $db->fetch_object($res)) { $event = new ActionComm($db); $event->fetch($obj->id); $event->fetch_userassigned(); $event->color = $obj->color; $TEventObject[] = $event; } foreach ($TEventObject as &$event) { if ($event->socid > 0 && !isset($TSociete[$event->socid])) { $societe = new Societe($db); $societe->fetch($event->socid); $TSociete[$event->socid] = $societe->getNomUrl(1); } if ($event->contactid > 0 && !isset($TContact[$event->contactid])) { $contact = new Contact($db); $contact->fetch($event->contactid); $TContact[$event->contactid] = $contact->getNomUrl(1); } $TUserassigned = array(); $TColor = array(); if ($event->color && empty($conf->global->FULLCALENDAR_USE_ASSIGNED_COLOR)) { $TColor[] = '#' . $event->color; } if (!empty($conf->global->FULLCALENDAR_SHOW_AFFECTED_USER)) { $userownerid = (int) $event->userownerid; if ($userownerid > 0 && !isset($TUser[$userownerid])) { $u = new User($db); $u->fetch($userownerid); $TUser[$userownerid] = $u; } $TUserassigned[$userownerid] = $TUser[$userownerid]->getNomUrl(1); } if (!empty($conf->global->FULLCALENDAR_SHOW_PROJECT) && $event->fk_project > 0 && !isset($TProject[$event->fk_project])) { $p = new Project($db); $p->fetch($event->fk_project); $TProject[$event->fk_project] = $p->getNomUrl(1); } if (!empty($conf->global->FULLCALENDAR_SHOW_AFFECTED_USER) && !empty($event->userassigned)) { foreach ($event->userassigned as &$ua) { $userid = (int) $ua['id']; if (!isset($TUser[$userid])) { $u = new User($db); $u->fetch($userid); $TUser[$userid] = $u; } if (!isset($TUserassigned[$userid])) { $TUserassigned[] = $TUser[$userid]->getNomUrl(1); } if ($TUser[$userid]->color && !in_array('#' . $TUser[$userid]->color, $TColor)) { $TColor[] = '#' . $TUser[$userid]->color; } } } $editable = false; if ($user->id == $event->userownerid || $user->rights->agenda->allactions->create) { $editable = true; } //background: linear-gradient(to bottom, #1e5799 0%,#2989d8 25%,#207cca 67%,#7db9e8 100%); //$colors = implode(',',$TColor); $colors = ''; $color = ''; if (!empty($TColor)) { $color = $TColor[0]; if (!empty($conf->global->FULLCALENDAR_SHOW_ALL_ASSIGNED_COLOR) && count($TColor) > 1) { $colors = 'linear-gradient(to right '; foreach ($TColor as $c) { $colors .= ',' . $c; } $colors .= ')'; } } $TEvent[] = array('id' => $event->id, 'title' => $event->label, 'allDay' => (bool) $event->fulldayevent, 'start' => empty($event->datep) ? '' : date('Y-m-d H:i:s', (int) $event->datep), 'end' => empty($event->datef) ? '' : date('Y-m-d H:i:s', (int) $event->datef), 'url' => dol_buildpath('/comm/action/card.php?id=' . $event->id, 1), 'editable' => $editable, 'color' => $color, 'isDarkColor' => isDarkColor($color), 'colors' => $colors, 'note' => $event->note, 'statut' => $event->getLibStatut(3), 'fk_soc' => $event->socid, 'fk_contact' => $event->contactid, 'fk_user' => $event->userownerid, 'fk_project' => $event->fk_project, 'societe' => !empty($TSociete[$event->socid]) ? $TSociete[$event->socid] : '', 'contact' => !empty($TContact[$event->contactid]) ? $TContact[$event->contactid] : '', 'user' => !empty($TUserassigned) ? implode(', ', $TUserassigned) : '', 'project' => !empty($TProject[$event->fk_project]) ? $TProject[$event->fk_project] : '', 'more' => ''); } $use_workstation_color = null; if (GETPOST('use_workstation_color')) { $use_workstation_color = 1; } //TODO getCalendarEvents compatbile standard // Complete $eventarray with events coming from external module $parameters = array('use_workstation_color' => $use_workstation_color, 'sql' => $sql); $action = 'getEvents'; $reshook = $hookmanager->executeHooks('updateFullcalendarEvents', $parameters, $TEvent, $action); if (!empty($hookmanager->resArray['eventarray'])) { $TEvent = array_merge($TEvent, $hookmanager->resArray['eventarray']); } return $TEvent; }
case 'ISO-8859-1': case 'ISO-8859-15': $htmlmsg = utf8_encode($htmlmsg); $plainmsg = utf8_encode(nl2br($plainmsg)); break; default: $plainmsg = nl2br($plainmsg); } if ($htmlmsg != '') { $corps = $htmlmsg; } else { $corps = $plainmsg; } } imap_close($mbox); $actioncomm = new ActionComm($db); $cactioncomm = new CActionComm($db); // Initialisation objet actioncomm $usertodo = $user; $actioncomm->usertodo = $usertodo; if (GETPOST('reference_fk_socid', 'int') > 0) { $societe = new Societe($db); $societe->fetch(GETPOST('reference_fk_socid', 'int')); $actioncomm->societe = $societe; } if ($conf->global->CODE_ACTIONCOMM_WEBMAIL) { $cactioncomm_code = $conf->global->CODE_ACTIONCOMM_WEBMAIL; } else { $cactioncomm_code = "AC_OTH"; } $result = $cactioncomm->fetch($cactioncomm_code);
/** * Show list of actions for element * * @param Object $object Object * @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter' * @param int $socid socid of user * @param int $forceshowtitle Show title even if there is no actions to show * @return int <0 if KO, >=0 if OK */ function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0) { global $langs, $conf, $user; global $bc; require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement); if (!is_array($listofactions)) { dol_print_error($this->db, 'FailedToGetActions'); } $num = count($listofactions); if ($num || $forceshowtitle) { if ($typeelement == 'invoice') { $title = $langs->trans('ActionsOnBill'); } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') { $title = $langs->trans('ActionsOnBill'); } elseif ($typeelement == 'propal') { $title = $langs->trans('ActionsOnPropal'); } elseif ($typeelement == 'supplier_proposal') { $title = $langs->trans('ActionsOnSupplierProposal'); } elseif ($typeelement == 'order') { $title = $langs->trans('ActionsOnOrder'); } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') { $title = $langs->trans('ActionsOnOrder'); } elseif ($typeelement == 'project') { $title = $langs->trans('ActionsOnProject'); } elseif ($typeelement == 'shipping') { $title = $langs->trans('ActionsOnShipping'); } elseif ($typeelement == 'fichinter') { $title = $langs->trans('ActionsOnFicheInter'); } else { $title = $langs->trans("Actions"); } print load_fiche_titre($title, '', ''); $total = 0; $var = true; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<th class="liste_titre">' . $langs->trans('Ref') . '</th>'; print '<th class="liste_titre">' . $langs->trans('Action') . '</th>'; print '<th class="liste_titre">' . $langs->trans('Date') . '</th>'; print '<th class="liste_titre">' . $langs->trans('By') . '</th>'; print '<th class="liste_titre" align="right">' . $langs->trans('Status') . '</th>'; print '</tr>'; print "\n"; $userstatic = new User($this->db); foreach ($listofactions as $action) { $ref = $action->getNomUrl(1, -1); $label = $action->getNomUrl(0, 38); $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>' . $ref . '</td>'; print '<td>' . $label . '</td>'; print '<td>' . dol_print_date($action->datep, 'dayhour'); if ($action->datef) { $tmpa = dol_getdate($action->datep); $tmpb = dol_getdate($action->datef); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) { print '-' . dol_print_date($action->datef, 'hour'); } } else { print '-' . dol_print_date($action->datef, 'dayhour'); } } print '</td>'; print '<td>'; if (!empty($action->author->id)) { $userstatic->id = $action->author->id; $userstatic->firstname = $action->author->firstname; $userstatic->lastname = $action->author->lastname; print $userstatic->getNomUrl(1); } print '</td>'; print '<td align="right">'; if (!empty($action->author->id)) { print $action->getLibStatut(3); } print '</td>'; print '</tr>'; } print '</table>'; } return $num; }
$langs->load("other"); $langs->load("bills"); $objectid = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check $socid = GETPOST('socid', 'int'); if ($user->societe_id) { $socid = $user->societe_id; } if ($user->societe_id > 0) { unset($_GET["action"]); $action = ''; } $result = restrictedArea($user, 'agenda', $objectid, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); $object = new ActionComm($db); if ($objectid > 0) { $ret = $object->fetch($objectid); if ($ret > 0) { $company = new Societe($db); $company->fetch($object->societe->id); $object->societe = $company; // For backward compatibility $object->thirdparty = $company; } } // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if ($page == -1) {
/** * Show html area with actions done * * @param Conf $conf Object conf * @param Translate $langs Object langs * @param DoliDB $db Object db * @param Object $object Object third party or member * @param Contact $objcon Object contact * @param int $noprint Return string but does not output it * @return mixed Return html part or void if noprint is 1 * TODO change function to be able to list event linked to an object. */ function show_actions_done($conf, $langs, $db, $object, $objcon = '', $noprint = 0) { global $bc, $user; // Check parameters if (!is_object($object)) { dol_print_error('', 'BadParameter'); } $out = ''; $histo = array(); $numaction = 0; $now = dol_now('tzuser'); if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm $sql = "SELECT a.id, a.label,"; $sql .= " a.datep as dp,"; $sql .= " a.datep2 as dp2,"; $sql .= " a.note, a.percent,"; $sql .= " a.fk_element, a.elementtype,"; $sql .= " a.fk_user_author, a.fk_contact,"; $sql .= " c.code as acode, c.libelle,"; $sql .= " u.login, u.rowid as user_id"; if (get_class($object) == 'Adherent') { $sql .= ", m.lastname, m.firstname"; } if (get_class($object) == 'Societe') { $sql .= ", sp.lastname, sp.firstname"; } $sql .= " FROM " . MAIN_DB_PREFIX . "c_actioncomm as c, " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a"; if (get_class($object) == 'Adherent') { $sql .= ", " . MAIN_DB_PREFIX . "adherent as m"; } if (get_class($object) == 'Societe') { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid"; } $sql .= " WHERE u.rowid = a.fk_user_author"; $sql .= " AND a.entity IN (" . getEntity('agenda', 1) . ")"; if (get_class($object) == 'Adherent') { $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; } if (get_class($object) == 'Adherent' && $object->id) { $sql .= " AND a.fk_element = " . $object->id; } if (get_class($object) == 'Societe' && $object->id) { $sql .= " AND a.fk_soc = " . $object->id; } if (is_object($objcon) && $objcon->id) { $sql .= " AND a.fk_contact = " . $objcon->id; } $sql .= " AND c.id=a.fk_action"; $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '" . $db->idate($now) . "'))"; $sql .= " ORDER BY a.datep DESC, a.id DESC"; dol_syslog("company.lib::show_actions_done sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); $var = true; while ($i < $num) { $obj = $db->fetch_object($resql); $histo[$numaction] = array('type' => 'action', 'id' => $obj->id, 'datestart' => $db->jdate($obj->dp), 'date' => $db->jdate($obj->dp2), 'note' => $obj->label, 'percent' => $obj->percent, 'acode' => $obj->acode, 'libelle' => $obj->libelle, 'userid' => $obj->user_id, 'login' => $obj->login, 'contact_id' => $obj->fk_contact, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'fk_element' => $obj->fk_element, 'elementtype' => $obj->elementtype); $numaction++; $i++; } } else { dol_print_error($db); } } if (!empty($conf->mailing->enabled) && !empty($objcon->email)) { $langs->load("mails"); // Recherche histo sur mailing $sql = "SELECT m.rowid as id, mc.date_envoi as da, m.titre as note, '100' as percentage,"; $sql .= " 'AC_EMAILING' as acode,"; $sql .= " u.rowid as user_id, u.login"; // User that valid action $sql .= " FROM " . MAIN_DB_PREFIX . "mailing as m, " . MAIN_DB_PREFIX . "mailing_cibles as mc, " . MAIN_DB_PREFIX . "user as u"; $sql .= " WHERE mc.email = '" . $db->escape($objcon->email) . "'"; // Search is done on email. $sql .= " AND mc.statut = 1"; $sql .= " AND u.rowid = m.fk_user_valid"; $sql .= " AND mc.fk_mailing=m.rowid"; $sql .= " ORDER BY mc.date_envoi DESC, m.rowid DESC"; dol_syslog("company.lib::show_actions_done sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); $var = true; while ($i < $num) { $obj = $db->fetch_object($resql); $histo[$numaction] = array('type' => 'mailing', 'id' => $obj->id, 'date' => $db->jdate($obj->da), 'note' => $obj->note, 'percent' => $obj->percentage, 'acode' => $obj->acode, 'userid' => $obj->user_id, 'login' => $obj->login); $numaction++; $i++; } $db->free($resql); } else { dol_print_error($db); } } if (!empty($conf->agenda->enabled) || !empty($conf->mailing->enabled) && !empty($objcon->email)) { require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $actionstatic = new ActionComm($db); $userstatic = new User($db); $contactstatic = new Contact($db); // TODO uniformize $propalstatic = new Propal($db); $orderstatic = new Commande($db); $facturestatic = new Facture($db); $out .= "\n"; $out .= '<table class="noborder" width="100%">'; $out .= '<tr class="liste_titre">'; $out .= '<td colspan="2">'; if (get_class($object) == 'Societe') { $out .= '<a href="' . DOL_URL_ROOT . '/comm/action/listactions.php?socid=' . $object->id . '&status=done">'; } $out .= $langs->trans("ActionsDoneShort"); if (get_class($object) == 'Societe') { $out .= '</a>'; } $out .= '</td>'; $out .= '<td colspan="5" align="right">'; $permok = $user->rights->agenda->myactions->create; if ((!empty($object->id) || !empty($objcon->id)) && $permok) { $out .= '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create'; if (get_class($object) == 'Societe') { $out .= '&socid=' . $object->id; } $out .= (!empty($objcon->id) ? '&contactid=' . $objcon->id : '') . '&backtopage=1&percentage=-1">'; $out .= $langs->trans("AddAnAction") . ' '; $out .= img_picto($langs->trans("AddAnAction"), 'filenew'); $out .= "</a>"; } $out .= '</td>'; $out .= '</tr>'; foreach ($histo as $key => $value) { $var = !$var; $out .= "<tr " . $bc[$var] . ">"; // Champ date $out .= '<td width="120" class="nowrap">'; if ($histo[$key]['date']) { $out .= dol_print_date($histo[$key]['date'], 'dayhour'); } else { if ($histo[$key]['datestart']) { $out .= dol_print_date($histo[$key]['datestart'], 'dayhour'); } } $out .= "</td>\n"; // Picto $out .= '<td width="16"> </td>'; // Action $out .= '<td>'; if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') { $actionstatic->type_code = $histo[$key]['acode']; $transcode = $langs->trans("Action" . $histo[$key]['acode']); $libelle = $transcode != "Action" . $histo[$key]['acode'] ? $transcode : $histo[$key]['libelle']; //$actionstatic->libelle=$libelle; $actionstatic->libelle = $histo[$key]['note']; $actionstatic->id = $histo[$key]['id']; $out .= $actionstatic->getNomUrl(1, 40); } if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { $out .= '<a href="' . DOL_URL_ROOT . '/comm/mailing/fiche.php?id=' . $histo[$key]['id'] . '">' . img_object($langs->trans("ShowEMailing"), "email") . ' '; $transcode = $langs->trans("Action" . $histo[$key]['acode']); $libelle = $transcode != "Action" . $histo[$key]['acode'] ? $transcode : 'Send mass mailing'; $out .= dol_trunc($libelle, 40); } $out .= '</td>'; // Title of event //$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>'; // Objet lie // TODO uniformize $out .= '<td>'; if (isset($histo[$key]['elementtype'])) { if ($histo[$key]['elementtype'] == 'propal' && !empty($conf->propal->enabled)) { $propalstatic->ref = $langs->trans("ProposalShort"); $propalstatic->id = $histo[$key]['fk_element']; $out .= $propalstatic->getNomUrl(1); } elseif ($histo[$key]['elementtype'] == 'commande' && !empty($conf->commande->enabled)) { $orderstatic->ref = $langs->trans("Order"); $orderstatic->id = $histo[$key]['fk_element']; $out .= $orderstatic->getNomUrl(1); } elseif ($histo[$key]['elementtype'] == 'facture' && !empty($conf->facture->enabled)) { $facturestatic->ref = $langs->trans("Invoice"); $facturestatic->id = $histo[$key]['fk_element']; $facturestatic->type = $histo[$key]['ftype']; $out .= $facturestatic->getNomUrl(1, 'compta'); } else { $out .= ' '; } } else { $out .= ' '; } $out .= '</td>'; // Contact pour cette action if (!empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { $contactstatic->lastname = $histo[$key]['lastname']; $contactstatic->firstname = $histo[$key]['firstname']; $contactstatic->id = $histo[$key]['contact_id']; $out .= '<td width="120">' . $contactstatic->getNomUrl(1, '', 10) . '</td>'; } else { $out .= '<td> </td>'; } // Auteur $out .= '<td class="nowrap" width="80">'; $userstatic->id = $histo[$key]['userid']; $userstatic->login = $histo[$key]['login']; $out .= $userstatic->getLoginUrl(1); $out .= '</td>'; // Statut $out .= '<td class="nowrap" width="20">' . $actionstatic->LibStatut($histo[$key]['percent'], 3) . '</td>'; $out .= "</tr>\n"; $i++; } $out .= "</table>\n"; $out .= "<br>\n"; } if ($noprint) { return $out; } else { print $out; } }
if ($dateselect > 0) { $sql .= " AND ((a.datep2 >= '" . $db->idate($dateselect) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "') OR (a.datep2 IS NULL AND a.datep > '" . $db->idate($dateselect - 3600) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "'))"; } if ($datestart > 0) { $sql .= " AND a.datep BETWEEN '" . $db->idate($datestart) . "' AND '" . $db->idate($datestart + 3600 * 24 - 1) . "'"; } if ($dateend > 0) { $sql .= " AND a.datep2 BETWEEN '" . $db->idate($dateend) . "' AND '" . $db->idate($dateend + 3600 * 24 - 1) . "'"; } $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); //print $sql; dol_syslog("comm/action/listactions.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $actionstatic = new ActionComm($db); $societestatic = new Societe($db); $num = $db->num_rows($resql); /*$title=$langs->trans("DoneAndToDoActions"); if ($status == 'done') $title=$langs->trans("DoneActions"); if ($status == 'todo') $title=$langs->trans("ToDoActions"); */ $title = $langs->trans("ListOfEvents"); $newtitle = $langs->trans($title); $tabactive = 'cardlist'; $head = calendars_prepare_head($param); dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup); dol_fiche_end(); // Add link to show birthdays $link = '';
if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } /* * View */ $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); $act = new ActionComm($db); $act->fetch($_GET["id"]); $act->info($_GET["id"]); $head=actions_prepare_head($act); dol_fiche_head($head, 'info', $langs->trans("Action"),0,'action'); print '<table width="100%"><tr><td>'; dol_print_object_info($act); print '</td></tr></table>'; print '</div>'; $db->close();
/** * Show list of actions for element * * @param Object $object Object * @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter' * @param int $socid socid of user * @param int $forceshowtitle Show title even if there is no actions to show * @return int <0 if KO, >=0 if OK */ function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0) { global $langs, $conf, $user; global $bc; require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement); if (!is_array($listofactions)) { dol_print_error($this->db, 'FailedToGetActions'); } $num = count($listofactions); if ($num || $forceshowtitle) { if ($typeelement == 'invoice') { $title = $langs->trans('ActionsOnBill'); } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') { $title = $langs->trans('ActionsOnBill'); } elseif ($typeelement == 'propal') { $title = $langs->trans('ActionsOnPropal'); } elseif ($typeelement == 'order') { $title = $langs->trans('ActionsOnOrder'); } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') { $title = $langs->trans('ActionsOnOrder'); } elseif ($typeelement == 'project') { $title = $langs->trans('ActionsOnProject'); } elseif ($typeelement == 'shipping') { $title = $langs->trans('ActionsOnShipping'); } elseif ($typeelement == 'fichinter') { $title = $langs->trans('ActionsOnFicheInter'); } else { $title = $langs->trans("Actions"); } print_titre($title); $total = 0; $var = true; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<th class="liste_titre">' . $langs->trans('Ref') . '</th>'; print '<th class="liste_titre">' . $langs->trans('Action') . '</th>'; print '<th class="liste_titre">' . $langs->trans('Date') . '</th>'; print '<th class="liste_titre">' . $langs->trans('By') . '</th>'; print '</tr>'; print "\n"; $userstatic = new User($this->db); foreach ($listofactions as $action) { $savlabel = $action->label; $action->label = $action->ref; $ref = $action->getNomUrl(1); $action->label = $savlabel; $label = $action->getNomUrl(0, 38); $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>' . $ref . '</td>'; print '<td>' . $label . '</td>'; print '<td>' . dol_print_date($action->datep, 'day') . '</td>'; print '<td>'; if (!empty($action->author->id)) { $userstatic->id = $action->author->id; $userstatic->firstname = $action->author->firstname; $userstatic->lastname = $action->author->lastname; print $userstatic->getNomUrl(1); } print '</td>'; print '</tr>'; } print '</table>'; } return $num; }
/** * Load all objects with filters * * @param DoliDb $db Database handler * @param int $socid Filter by thirdparty * @param int $fk_element Id of element action is linked to * @param string $elementtype Type of element action is linked to * @param string $filter Other filter * @param string $sortfield Sort on this field * @param string $sortorder ASC or DESC * @return array or string Error string if KO, array with actions if OK */ static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = '', $sortorder = '') { global $conf, $langs; $resarray = array(); $sql = "SELECT a.id"; $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a"; $sql .= " WHERE a.entity IN (" . getEntity('actioncomm', 1) . ")"; if (!empty($socid)) { $sql .= " AND a.fk_soc = " . $socid; } if (!empty($elementtype)) { if ($elementtype == 'project') { $sql .= ' AND a.fk_project = ' . $fk_element; } else { $sql .= " AND a.fk_element = " . $fk_element . " AND a.elementtype = '" . $elementtype . "'"; } } if (!empty($filter)) { $sql .= $filter; } if ($sortorder && $sortfield) { $sql .= $db->order($sortfield, $sortorder); } dol_syslog(get_class() . "::getActions", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { for ($i = 0; $i < $num; $i++) { $obj = $db->fetch_object($resql); $actioncommstatic = new ActionComm($db); $actioncommstatic->fetch($obj->id); $resarray[$i] = $actioncommstatic; } } $db->free($resql); return $resarray; } else { return $db->lasterror(); } }
/** * Load data for box to show them later * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $actionstatic = new ActionComm($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo", $max)); if ($user->rights->agenda->myactions->read) { $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage,"; $sql .= " ta.code,"; $sql .= " s.nom, s.rowid as socid"; $sql .= " FROM (" . MAIN_DB_PREFIX . "c_actioncomm AS ta, "; $sql .= MAIN_DB_PREFIX . "actioncomm AS a)"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; } $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE a.fk_action = ta.id"; $sql .= " AND a.entity = " . $conf->entity; $sql .= " AND a.percent >= 0 AND a.percent < 100"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = "******")"; } if ($user->societe_id) { $sql .= " AND s.rowid = " . $user->societe_id; } if (!$user->rights->agenda->allactions->read) { $sql .= " AND (a.fk_user_author = " . $user->id . " OR a.fk_user_action = " . $user->id . " OR a.fk_user_done = " . $user->id . ")"; } $sql .= " ORDER BY a.datec DESC"; $sql .= $db->plimit($max, 0); dol_syslog("Box_actions::loadBox sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; $num = $db->num_rows($result); $i = 0; while ($i < $num) { $late = ''; $objp = $db->fetch_object($result); $datelimite = $db->jdate($objp->dp); if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < $now - $delay_warning) { $late = img_warning($langs->trans("Late")); } //($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) $label = $objp->label; $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => "action", 'url' => DOL_URL_ROOT . "/comm/action/fiche.php?id=" . $objp->id); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => dol_trunc($label, 32), 'text2' => $late, 'url' => DOL_URL_ROOT . "/comm/action/fiche.php?id=" . $objp->id); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => $objp->socid ? 'company' : '', 'url' => $objp->socid ? DOL_URL_ROOT . "/societe/soc.php?socid=" . $objp->socid : ''); $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($objp->nom, 24), 'url' => DOL_URL_ROOT . "/societe/soc.php?socid=" . $objp->socid); $this->info_box_contents[$i][4] = array('td' => 'align="left" class="nowrap"', 'text' => dol_print_date($datelimite, "dayhour")); $this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => $objp->percentage >= 0 ? $objp->percentage . '%' : ''); $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', 'text' => $actionstatic->LibStatut($objp->percentage, 3)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoActionsToDo")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
$shortfilename .= '.ics'; $filename .= '.ics'; } if ($format == 'rss') { $shortfilename .= '.rss'; $filename .= '.rss'; } if ($shortfilename == 'dolibarrcalendar') { $langs->load("main"); $langs->load("errors"); llxHeaderVierge(); print '<div class="error">' . $langs->trans("ErrorWrongValueForParameterX", 'format') . '</div>'; llxFooterVierge(); exit; } $agenda = new ActionComm($db); $cachedelay = 0; if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)) { $cachedelay = $conf->global->MAIN_AGENDA_EXPORT_CACHE; } // Build file if ($format == 'ical' || $format == 'vcal') { $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters); if ($result >= 0) { $attachment = true; if (isset($_GET["attachment"])) { $attachment = $_GET["attachment"]; } //$attachment = false; $contenttype = 'text/calendar'; if (isset($_GET["contenttype"])) {
/** * Create ActionComm * * @param array $authentication Array of authentication information * @param ActionComm $actioncomm $actioncomm * @return array Array result */ function updateActionComm($authentication, $actioncomm) { global $db, $conf, $langs; $now = dol_now(); dol_syslog("Function: updateActionComm login="******"Actioncomm id is mandatory."; } if (!$error) { $objectfound = false; $object = new ActionComm($db); $result = $object->fetch($actioncomm['id']); if (!empty($object->id)) { $objectfound = true; $object->datep = $actioncomm['datep']; $object->datef = $actioncomm['datef']; $object->type_code = $actioncomm['type_code']; $object->societe->id = $actioncomm['socid']; $object->fk_project = $actioncomm['projectid']; $object->note = $actioncomm['note']; $object->contact->id = $actioncomm['contactid']; $object->usertodo->id = $actioncomm['usertodo']; $object->userdone->id = $actioncomm['userdone']; $object->label = $actioncomm['label']; $object->percentage = $actioncomm['percentage']; $object->priority = $actioncomm['priority']; $object->fulldayevent = $actioncomm['fulldayevent']; $object->location = $actioncomm['location']; $object->fk_element = $actioncomm['fk_element']; $object->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; $object->array_options[$key] = $actioncomm[$key]; } $db->begin(); $result = $object->update($fuser); if ($result <= 0) { $error++; } } if (!$error && $objectfound) { $db->commit(); $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id); } elseif ($objectfound) { $db->rollback(); $error++; $errorcode = 'KO'; $errorlabel = $object->error; } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Actioncomm id=' . $actioncomm['id'] . ' cannot be found'; } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
print '<th class="liste_titre" align="right">' . $langs->trans("Number") . '</th>'; print '<th class="liste_titre" align="right">' . $langs->trans("Late") . '</th>'; print '<th class="liste_titre"> </th>'; print '<th class="liste_titre" width="20"> </th>'; if ($showweather) { print '<th class="liste_titre hideonsmartphone" width="80"> </th>'; } print '</tr>' . "\n"; // // Do not include sections without management permission // require DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php'; // Number of actions to do (late) if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) { include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $board = new ActionComm($db); $dashboardlines[] = $board->load_board($user); } // Number of customer orders a deal if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $board = new Commande($db); $dashboardlines[] = $board->load_board($user); } // Number of suppliers orders a deal if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; $board = new CommandeFournisseur($db); $dashboardlines[] = $board->load_board($user); } // Number of commercial proposals opened (expired)
/** * 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; }
/** * Load all objects with filters * @param socid Filter by thirdparty * @param fk_element Id of element action is linked to * @param elementtype Type of element action is linked to * @param filter Other filter */ function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '') { global $conf, $langs; $sql = "SELECT a.id"; $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a"; $sql .= " WHERE a.entity = " . $conf->entity; if (!empty($socid)) { $sql .= " AND a.fk_soc = " . $socid; } if (!empty($elementtype)) { if ($elementtype == 'project') { $sql .= ' AND a.fk_project = ' . $fk_element; } else { $sql .= " AND a.fk_element = " . $fk_element . " AND a.elementtype = '" . $elementtype . "'"; } } if (!empty($filter)) { $sql .= $filter; } dol_syslog("ActionComm::getActions sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { for ($i = 0; $i < $num; $i++) { $obj = $this->db->fetch_object($resql); $actioncommstatic = new ActionComm($this->db); $actioncommstatic->fetch($obj->id); $this->actions[$i] = $actioncommstatic; } } $this->db->free($resql); return 1; } else { $this->error = $this->db->lasterror(); return -1; } }
$datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour"), $fulldayevent ? '00' : GETPOST("apmin"), 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour"), $fulldayevent ? '59' : GETPOST("p2min"), $fulldayevent ? '59' : '0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year")); // Security check $socid = GETPOST('socid', 'int'); $id = GETPOST('id', 'int'); if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); if ($user->societe_id && $socid) { $result = restrictedArea($user, 'societe', $socid); } $error = GETPOST("error"); $donotclearsession = GETPOST('donotclearsession') ? GETPOST('donotclearsession') : 0; $cactioncomm = new CActionComm($db); $object = new ActionComm($db); $contact = new Contact($db); $extrafields = new ExtraFields($db); $formfile = new FormFile($db); $form = new Form($db); $formfile = new FormFile($db); $formactions = new FormActions($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); //var_dump($_POST); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('actioncard', 'globalcard')); /* * Actions */ $listUserAssignedUpdated = false;
if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'societe', $socid, '&societe'); $object = new Prospect($db); /* * Actions */ if ($_GET["action"] == 'cstc') { $sql = "UPDATE " . MAIN_DB_PREFIX . "societe SET fk_stcomm = " . $_GET["stcomm"]; $sql .= " WHERE rowid = " . $_GET["socid"]; $db->query($sql); $actioncomm = new ActionComm($db); $actioncomm->addAutoTask('AC_PROSPECT', $_GET["stcomm"] . " Statut de prospection : " . $obj->libelle, $_GET["socid"], '', ''); if ($objp->fk_stcomm == 0 && $_GET["stcomm"] > 0) { $actioncomm = new ActionComm($db); $actioncomm->addAutoTask('AC_SUSP', "Statut de prospection : " . $obj->libelle, $_GET["socid"], '', ''); } if (!empty($_GET["backtopage"])) { header("Location: " . $_GET["backtopage"]); } } // set prospect level if ($_POST["action"] == 'setprospectlevel' && $user->rights->societe->creer) { $object->fetch($_GET["socid"]); $object->fk_prospectlevel = $_POST['prospect_level_id']; $sql = "UPDATE " . MAIN_DB_PREFIX . "societe SET fk_prospectlevel='" . $_POST['prospect_level_id']; $sql .= "' WHERE rowid='" . $_GET["socid"] . "'"; $result = $db->query($sql); if (!$result) { dol_print_error($result);