26 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
34 public $boxcode =
"lastcontracts";
35 public $boximg =
"object_contract";
36 public $boxlabel =
"BoxLastContracts";
37 public $depends = array(
"contrat");
46 public $info_box_head = array();
47 public $info_box_contents = array();
62 $this->hidden = empty($user->rights->contrat->lire);
73 global $user, $langs, $conf;
77 include_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
79 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastContracts", $max));
81 if ($user->rights->contrat->lire) {
85 $sql =
"SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
86 $sql .=
" c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.tms as date_modification, c.fin_validite, c.date_cloture,";
87 $sql .=
" c.ref_customer, c.ref_supplier";
88 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"contrat as c";
89 if (empty($user->rights->societe->client->voir) && !$user->socid) {
90 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
92 $sql .=
" WHERE c.fk_soc = s.rowid";
93 $sql .=
" AND c.entity = ".$conf->entity;
94 if (empty($user->rights->societe->client->voir) && !$user->socid) {
95 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
98 $sql .=
" AND s.rowid = ".((int) $user->socid);
100 if (! empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
101 $sql .=
" ORDER BY c.date_contrat DESC, c.ref DESC ";
103 $sql .=
" ORDER BY c.tms DESC, c.ref DESC ";
105 $sql .= $this->
db->plimit($max, 0);
114 $langs->load(
"contracts");
116 while ($line < $num) {
117 $objp = $this->
db->fetch_object(
$resql);
119 $datec = $this->
db->jdate($objp->datec);
120 $datem = $this->
db->jdate($objp->date_modification);
121 $dateterm = $this->
db->jdate($objp->fin_validite);
122 $dateclose = $this->
db->jdate($objp->date_cloture);
125 $contractstatic->statut = $objp->fk_statut;
126 $contractstatic->id = $objp->rowid;
127 $contractstatic->ref = $objp->ref;
128 $contractstatic->ref_customer = $objp->ref_customer;
129 $contractstatic->ref_supplier = $objp->ref_supplier;
130 $result = $contractstatic->fetch_lines();
132 $thirdpartytmp->name = $objp->name;
133 $thirdpartytmp->id = $objp->socid;
134 $thirdpartytmp->email = $objp->email;
135 $thirdpartytmp->client = $objp->client;
136 $thirdpartytmp->fournisseur = $objp->fournisseur;
137 $thirdpartytmp->code_client = $objp->code_client;
138 $thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
139 $thirdpartytmp->code_compta = $objp->code_compta;
140 $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
145 $this->info_box_contents[$line][] = array(
146 'td' =>
'class="nowraponall"',
147 'text' => $contractstatic->getNomUrl(1),
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
154 'text' => $thirdpartytmp->getNomUrl(1),
158 $this->info_box_contents[$line][] = array(
163 $this->info_box_contents[$line][] = array(
164 'td' =>
'class="nowraponall right"',
165 'text' => $contractstatic->getLibStatut(7),
173 $this->info_box_contents[$line][0] = array(
174 'td' =>
'class="center opacitymedium"',
175 'text'=>$langs->trans(
"NoRecordedContracts"),
181 $this->info_box_contents[0][0] = array(
184 'text' => ($this->
db->error().
' sql='.$sql),
188 $this->info_box_contents[0][0] = array(
189 'td' =>
'class="nohover opacitymedium left"',
190 'text' => $langs->trans(
"ReadPermissionNotAllowed")
203 public function showBox($head = null, $contents = null, $nooutput = 0)
205 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
__construct($db, $param)
Constructor.
$conf db
API class for accounts.
dol_now($mode= 'auto')
Return date for now.
Class to manage contracts.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage the box to show last contracts.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=5)
Load data for box to show them later.