/** * Load data into info_box_contents array to show array later. * * @param int $max of records to load * * @return void */ public function loadBox($max = 5) { global $conf, $user, $langs, $db; $this->max = $max; dol_include_once('/lead/class/lead.class.php'); $lead = new Lead($db); $lead->fetch_all('DESC', 't.date_closure', $max, 0, array('t.date_closure<' => dol_now())); $text = $langs->trans("LeadLate", $max); $this->info_box_head = array('text' => $text, 'limit' => dol_strlen($text)); $i = 0; foreach ($lead->lines as $line) { // FIXME: line is an array, not an object $line->fetch_thirdparty(); // Ref $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $line->ref, 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc); $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($line->thirdparty->name, 40), 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc); // Amount Guess $this->info_box_contents[$i][4] = array('td' => 'align="left"', 'text' => price($line->amount_prosp, 'HTML') . $langs->getCurrencySymbol($conf->currency)); // Amount real $this->info_box_contents[$i][5] = array('td' => 'align="left"', 'text' => $line->getRealAmount() . $langs->getCurrencySymbol($conf->currency)); $i++; } }
$sortfield = "t.date_closure"; } $title = $langs->trans('LeadList'); llxHeader('', $title); if (!empty($socid)) { require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; $soc = new Societe($db); $soc->fetch($socid); $head = societe_prepare_head($soc); dol_fiche_head($head, 'tabLead', $langs->trans("Module103111Name"), 0, dol_buildpath('/lead/img/object_lead.png', 1), 1); } // Count total nb of records $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetch_all($sortorder, $sortfield, 0, 0, $filter); } $resql = $object->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); if ($resql != -1) { $num = $resql; print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', $num, $nbtotalofrecords); print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" name="search_form">' . "\n"; if (!empty($sortfield)) { print '<input type="hidden" name="sortfield" value="' . $sortfield . '"/>'; } if (!empty($sortorder)) { print '<input type="hidden" name="sortorder" value="' . $sortorder . '"/>'; } if (!empty($page)) { print '<input type="hidden" name="page" value="' . $page . '"/>'; }
/** * 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&socid=' . $object->socid . '&amount_guess=' . $object->total_ht . '&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>'; } } }
/** * Return combo list of differents type * * @param string $selected Value * @param string $htmlname Name of the component * @param int $showempty Row * @param array $filter Filter results * * @return string HTML select */ function select_lead($selected = '', $htmlname = 'leadid', $showempty = 1, $filter = array()) { $lead_array = array(); require_once 'lead.class.php'; $lead = new Lead($this->db); $result = $lead->fetch_all('DESC', 't.ref', 0, 0, $filter); if ($result < 0) { setEventMessages(null, $lead->errors, 'errors'); } foreach ($lead->lines as $line) { $lead_array[$line->id] = $line->ref . '-' . $line->ref_int . ' (' . $line->status_label . '-' . $line->type_label . ')'; } if (count($lead_array) > 0) { return $this->selectarray($htmlname, $lead_array, $selected, $showempty); } return null; }