66 global
$conf, $user, $langs;
68 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
69 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
77 $savMAIN_ACTIVATE_FILECACHE =
getDolGlobalInt(
'MAIN_ACTIVATE_FILECACHE');
78 $conf->global->MAIN_ACTIVATE_FILECACHE = 1;
81 $textHead = $langs->trans(
"InvoicesDispute").
' - '.$langs->trans(
"LastXMonthRolling", $nbofperiod);
82 $this->info_box_head = array(
91 if (
isModEnabled(
'invoice') && $user->hasRight(
"facture",
"lire")) {
92 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
93 $facturestatic =
new Facture($this->db);
96 $sql =
"SELECT f.dispute_status, f.fk_statut, SUM(f.total_ttc) as mnttot, COUNT(*) as nb";
97 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
98 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
99 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
102 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
103 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
104 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
107 $sql .=
" AND s.rowid = ".((int) $user->socid);
109 $sql .=
" AND f.fk_soc = s.rowid";
110 $sql .=
" AND f.dispute_status > 0";
111 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=1";
112 $sql .=
" GROUP BY f.dispute_status, f.fk_statut";
113 $sql .=
" ORDER BY f.dispute_status ASC";
115 $result = $this->db->query($sql);
117 $num = $this->db->num_rows($result);
120 $data[$j] = $this->db->fetch_object($result);
124 $this->db->free($result);
131 while ($j < count($data)) {
132 $billurl =
"search_status=2&paye=1&search_dispute_status=".$data[$j]->dispute_status;
133 $this->info_box_contents[$line][0] = array(
134 'td' =>
'class="left" width="16"',
135 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0, -1, -1, array(
"dispute_status" => $data[$j]->dispute_status)),
136 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
140 $this->info_box_contents[$line][1] = array(
142 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0, -1, -1, array(
"dispute_status" => $data[$j]->dispute_status)),
145 $this->info_box_contents[$line][2] = array(
146 'td' =>
'class="right"',
147 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0, -1, -1, array(
"dispute_status" => $data[$j]->dispute_status)),
148 'text' => $data[$j]->nb,
149 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
152 $this->info_box_contents[$line][3] = array(
153 'td' =>
'class="nowraponall right amount"',
154 'text' =>
price($data[$j]->mnttot, 1, $langs, 0, 0, -1,
$conf->currency)
158 $totalnb += $data[$j]->nb;
160 $this->info_box_contents[$line][4] = array(
161 'td' =>
'class="right" width="18"',
162 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3, -1, -1, array(
"dispute_status" => $data[$j]->dispute_status)),
167 if (count($data) == 0) {
168 $this->info_box_contents[$line][0] = array(
169 'td' =>
'class="center"',
170 'text' => $langs->trans(
"NoRecordedInvoices"),
177 $this->info_box_contents[$line][0] = array(
'tr' =>
'class="liste_total_wrap"');
178 $this->info_box_contents[$line][1] = array(
'td' =>
'class="liste_total left" ',
'text' => $langs->trans(
"Total").
" ".$textHead);
179 $this->info_box_contents[$line][2] = array(
'td' =>
'class="liste_total right" ',
'text' => (
string) $totalnb);
180 $this->info_box_contents[$line][3] = array(
'td' =>
'class="liste_total right" ',
'text' =>
'');
181 $this->info_box_contents[$line][4] = array(
'td' =>
'class="liste_total right" ',
'text' =>
"");
183 $conf->global->MAIN_ACTIVATE_FILECACHE = $savMAIN_ACTIVATE_FILECACHE;