/** * 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 . '/contrat/class/contrat.class.php'; $contractstatic = new Contrat($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); if ($user->rights->contrat->lire) { $sql = "SELECT s.nom, s.rowid as socid,"; $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "contrat as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity = " . $conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $now = dol_now(); $i = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $datec = $db->jdate($objp->datec); $dateterm = $db->jdate($objp->fin_validite); $dateclose = $db->jdate($objp->date_cloture); $late = ''; $contractstatic->statut = $objp->fk_statut; $contractstatic->id = $objp->rowid; $result = $contractstatic->fetch_lines(); // fin_validite is no more on contract but on services // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/contrat/fiche.php?id=" . $objp->rowid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref ? $objp->ref : $objp->rowid, 'text2' => $late, 'url' => DOL_URL_ROOT . "/contrat/fiche.php?id=" . $objp->rowid); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($objp->nom, 40), 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datec, 'day')); $this->info_box_contents[$i][5] = array('td' => 'align="right" class="nowrap"', 'text' => $contractstatic->getLibStatut(6), 'asis' => 1); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedContracts")); } $db->free($resql); } 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('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
} $i = 0; while ($i < $num && $i < $MAXLIST) { $contrat = new Contrat($db); $objp = $db->fetch_object($resql); $var = !$var; print "<tr {$bc[$var]}>"; print '<td nowrap="nowrap">'; $contrat->id = $objp->id; $contrat->ref = $objp->ref ? $objp->ref : $objp->id; print $contrat->getNomUrl(1, 12); print "</td>\n"; print '<td align="right" width="80">' . dol_print_date($db->jdate($objp->dc), 'day') . "</td>\n"; print '<td width="20"> </td>'; print '<td align="right" nowrap="nowrap">'; $contrat->fetch_lines(); print $contrat->getLibStatut(4); print "</td>\n"; print '</tr>'; $i++; } $db->free($resql); } else { dol_print_error($db); } print "</table>"; } /* * Last interventions */ if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) {
/* */ /* Mode vue et edition */ /* */ /* *************************************************************************** */ { $now=dol_now(); $id = $_GET["id"]; $ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { $result=$object->fetch($_GET['id'],$_GET['ref']); if ($result > 0) { $id = $object->id; // if $_GET['ref'] $result=$object->fetch_lines(); } if ($result < 0) { dol_print_error($db,$object->error); exit; } dol_htmloutput_errors($mesg,''); $nbofservices=sizeof($object->lines); $author = new User($db); $author->fetch($object->user_author_id); $commercial_signature = new User($db);