Exemple #1
0
 /**
  * addMoreActionsButtons Method Hook Call
  *
  * @param string[] $parameters parameters
  * @param CommonObject $object Object to use hooks on
  * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
  * @param HookManager $hookmanager class instance
  * @return void
  */
 function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
 {
     global $langs, $conf, $user, $db, $bc;
     $current_context = explode(':', $parameters['context']);
     if (in_array('commcard', $current_context)) {
         $langs->load("lead@lead");
         if ($user->rights->lead->write) {
             $html = '<div class="inline-block divButAction"><a class="butAction" href="' . dol_buildpath('/lead/lead/card.php', 1) . '?action=create&socid=' . $object->id . '">' . $langs->trans('LeadCreate') . '</a></div>';
         } else {
             $html = '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('LeadCreate') . '</a></div>';
         }
         $html = str_replace('"', '\\"', $html);
         print '<script type="text/javascript">jQuery(document).ready(function () {jQuery(function() {jQuery(".tabsAction").append("' . $html . '");});});</script>';
         if ($user->rights->lead->read) {
             require_once 'lead.class.php';
             $lead = new Lead($db);
             $filter['so.rowid'] = $object->id;
             $resql = $lead->fetch_all('DESC', 't.date_closure', 0, 0, $filter);
             if ($resql == -1) {
                 setEventMessages(null, $object->errors, 'errors');
             }
             $total_lead = count($lead->lines);
             // $filter['so.rowid'] = $object->id;
             $resql = $lead->fetch_all('DESC', 't.date_closure', 4, 0, $filter);
             if ($resql == -1) {
                 setEventMessages(null, $object->errors, 'errors');
             }
             $num = count($lead->lines);
             $html = '<table class="noborder" width="100%">';
             $html .= '<tr class="liste_titre">';
             $html .= '<td colspan="6">';
             $html .= '<table width="100%" class="nobordernopadding"><tr><td>' . $langs->trans("LeadLastLeadUpdated", $num <= 4 ? $num : 4) . '</td><td align="right"><a href="' . dol_buildpath('/lead/lead/list.php', 1) . '?socid=' . $object->id . '">' . $langs->trans("LeadList") . ' (' . $total_lead . ')</a></td>';
             $html .= '<td width="20px" align="right"><a href="' . dol_buildpath('/lead/index.php', 1) . '">' . img_picto($langs->trans("Statistics"), 'stats') . '</a></td>';
             $html .= '</tr></table></td>';
             $html .= '</tr>';
             foreach ($lead->lines as $lead_line) {
                 $var = !$var;
                 $html .= '<tr ' . $bc[$var] . '>';
                 $html .= '<td>' . $lead_line->getNomUrl(1) . '</td>';
                 $html .= '<td>' . $lead_line->ref_int . '</td>';
                 $html .= '<td>' . $lead_line->type_label . '</td>';
                 $html .= '<td>' . price($lead_line->amount_prosp) . ' ' . $langs->getCurrencySymbol($conf->currency) . '</td>';
                 $html .= '<td>' . dol_print_date($lead_line->date_closure, 'daytextshort') . '</td>';
                 $html .= '<td>' . $lead_line->getLibStatut(2) . '</td>';
                 $html .= '</tr>';
             }
             $html .= '</table>';
             $html = str_replace('"', '\\"', $html);
             print '<script type="text/javascript">jQuery(document).ready(function () {jQuery(function() {jQuery(".ficheaddleft").append("' . $html . '");});});</script>';
         }
     }
     if (in_array('propalcard', $current_context)) {
         require_once 'lead.class.php';
         $lead = new Lead($db);
         $ret = $lead->fetchLeadLink($object->rowid ? $id = $object->rowid : $object->id, $object->table_element);
         if ($ret < 0) {
             setEventMessages(null, $lead->errors, 'errors');
         }
         if (count($lead->doclines) == 0) {
             $langs->load("lead@lead");
             if ($user->rights->lead->write) {
                 $html = '<div class="inline-block divButAction"><a class="butAction" href="' . dol_buildpath('/lead/lead/card.php', 1) . '?action=create&amp;socid=' . $object->socid . '&amp;amount_guess=' . $object->total_ht . '&amp;propalid=' . $object->id . '">' . $langs->trans('LeadCreate') . '</a></div>';
             } else {
                 $html = '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('LeadCreate') . '</a></div>';
             }
             $html = str_replace('"', '\\"', $html);
             print '<script type="text/javascript">jQuery(document).ready(function () {jQuery(function() {jQuery(".tabsAction").append("' . $html . '");});});</script>';
         }
     }
 }