24 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
33 public $boxcode =
"expiredservices";
34 public $boximg =
"object_contract";
35 public $boxlabel =
"BoxOldestExpiredServices";
36 public $depends = array(
"contrat");
45 public $info_box_head = array();
46 public $info_box_contents = array();
61 $this->hidden = !($user->hasRight(
'contrat',
'lire'));
72 global $user, $langs, $conf;
76 include_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
80 $this->info_box_head = array(
'text' => $langs->trans(
"BoxLastExpiredServices", $max));
82 if ($user->rights->contrat->lire) {
85 $sql .=
" c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,";
86 $sql .=
" 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,";
87 $sql .=
" MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services";
88 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c, ".MAIN_DB_PREFIX.
"societe s, ".MAIN_DB_PREFIX.
"contratdet as cd";
89 if (empty($user->rights->societe->client->voir) && !$user->socid) {
90 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
92 $sql .=
" WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now).
"'";
93 $sql .=
" AND c.entity = ".$conf->entity;
94 $sql .=
" AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0";
96 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
98 if (empty($user->rights->societe->client->voir) && !$user->socid) {
99 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
101 $sql .=
" GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid";
102 $sql .=
", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
103 $sql .=
" ORDER BY date_line ASC";
104 $sql .= $this->
db->plimit($max, 0);
118 $objp = $this->
db->fetch_object(
$resql);
120 $thirdpartytmp->name = $objp->name;
121 $thirdpartytmp->id = $objp->socid;
122 $thirdpartytmp->email = $objp->email;
123 $thirdpartytmp->client = $objp->client;
124 $thirdpartytmp->fournisseur = $objp->fournisseur;
125 $thirdpartytmp->code_client = $objp->code_client;
126 $thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
127 $thirdpartytmp->code_compta = $objp->code_compta;
128 $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
130 $contract->id = $objp->rowid;
131 $contract->ref = $objp->ref;
132 $contract->statut = $objp->fk_statut;
133 $contract->ref_customer = $objp->ref_customer;
134 $contract->ref_supplier = $objp->ref_supplier;
136 $dateline = $this->
db->jdate($objp->date_line);
137 if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) {
141 $this->info_box_contents[$i][] = array(
142 'td' =>
'class="nowraponall"',
143 'text' => $contract->getNomUrl(1),
147 $this->info_box_contents[$i][] = array(
148 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone left"',
149 'text' => $thirdpartytmp->getNomUrl(1,
'customer'),
153 $this->info_box_contents[$i][] = array(
154 'td' =>
'class="center nowraponall" title="'.
dol_escape_htmltag($langs->trans(
"DateEndPlanned").
': '.
dol_print_date($dateline,
'dayhour',
'tzuserrel')).
'"',
159 $this->info_box_contents[$i][] = array(
160 'td' =>
'class="right"',
161 'text' => $objp->nb_services,
169 $langs->load(
"contracts");
170 $this->info_box_contents[$i][] = array(
171 'td' =>
'class="nohover opacitymedium center"',
172 'text' => $langs->trans(
"NoExpiredServices"),
178 $this->info_box_contents[0][] = array(
181 'text' => ($this->
db->error().
' sql='.$sql),
185 $this->info_box_contents[0][0] = array(
186 'td' =>
'class="nohover opacitymedium left"',
187 'text' => $langs->trans(
"ReadPermissionNotAllowed")
200 public function showBox($head =
null, $contents =
null, $nooutput = 0)
202 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage contracts.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage the box to show expired services.
loadBox($max=5)
Load data for box to show them later.
__construct($db, $param)
Constructor.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
$conf db
API class for accounts.