34 global $db, $langs, $conf, $user;
35 $langs->loadLangs(array(
'propal',
'compta',
'companies'));
40 $head[$h][0] = DOL_URL_ROOT.
'/comm/propal/card.php?id='.$object->id;
41 $head[$h][1] = $langs->trans(
'Proposal');
42 $head[$h][2] =
'comm';
45 if ((empty($conf->commande->enabled) && ((!empty($conf->expedition->enabled) && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
46 || (!empty($conf->expedition->enabled) && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) {
47 $langs->load(
"sendings");
49 $head[$h][0] = DOL_URL_ROOT.
'/expedition/propal.php?id='.$object->id;
50 if ($conf->expedition_bon->enabled) {
51 $text = $langs->trans(
"Shipment");
53 if ($conf->delivery_note->enabled) {
54 $text .=
'/'.$langs->trans(
"Receivings");
57 $head[$h][2] =
'shipping';
61 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
62 $nbContact = count($object->liste_contact(-1,
'internal')) + count($object->liste_contact(-1,
'external'));
63 $head[$h][0] = DOL_URL_ROOT.
'/comm/propal/contact.php?id='.$object->id;
64 $head[$h][1] = $langs->trans(
'ContactsAddresses');
66 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
68 $head[$h][2] =
'contact';
78 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
80 if (!empty($object->note_private)) {
83 if (!empty($object->note_public)) {
86 $head[$h][0] = DOL_URL_ROOT.
'/comm/propal/note.php?id='.$object->id;
87 $head[$h][1] = $langs->trans(
'Notes');
89 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
91 $head[$h][2] =
'note';
95 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
96 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
97 $upload_dir = $conf->propal->multidir_output[$object->entity].
"/".
dol_sanitizeFileName($object->ref);
98 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
99 $nbLinks =
Link::count($db, $object->element, $object->id);
100 $head[$h][0] = DOL_URL_ROOT.
'/comm/propal/document.php?id='.$object->id;
101 $head[$h][1] = $langs->trans(
'Documents');
102 if (($nbFiles + $nbLinks) > 0) {
103 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
105 $head[$h][2] =
'document';
108 $head[$h][0] = DOL_URL_ROOT.
'/comm/propal/info.php?id='.$object->id;
109 $head[$h][1] = $langs->trans(
'Info');
110 $head[$h][2] =
'info';
125 global $langs, $conf, $user;
130 $head[$h][0] = DOL_URL_ROOT.
'/admin/propal.php';
131 $head[$h][1] = $langs->trans(
"Miscellaneous");
132 $head[$h][2] =
'general';
141 $head[$h][0] = DOL_URL_ROOT.
'/comm/admin/propal_extrafields.php';
142 $head[$h][1] = $langs->trans(
"ExtraFields");
143 $head[$h][2] =
'attributes';
146 $head[$h][0] = DOL_URL_ROOT.
'/comm/admin/propaldet_extrafields.php';
147 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
148 $head[$h][2] =
'attributeslines';
166 global $conf, $db, $langs, $user;
170 if (empty($conf->propal->enabled) || empty($user->rights->propal->lire)) {
176 $propalstatic =
new Propal($db);
178 $sql =
"SELECT count(p.rowid) as nb, p.fk_statut as status";
179 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
180 $sql .=
", ".MAIN_DB_PREFIX.
"propal as p";
181 if (empty($user->rights->societe->client->voir) && !$socid) {
182 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
184 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
185 $sql .=
" AND p.fk_soc = s.rowid";
187 $sql .=
' AND p.fk_soc = '.((int) $user->socid);
189 if (empty($user->rights->societe->client->voir) && !$socid) {
190 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
192 $sql .=
" AND p.fk_statut IN (".$db->sanitize(implode(
" ,", $listofstatus)).
")";
193 $sql .=
" GROUP BY p.fk_statut";
194 $resql = $db->query($sql);
196 $num = $db->num_rows(
$resql);
200 $dataseries = array();
201 $colorseries = array();
205 $obj = $db->fetch_object(
$resql);
207 $vals[$obj->status] = $obj->nb;
208 $totalinprocess += $obj->nb;
216 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
218 $result =
'<div class="div-table-responsive-no-min">';
219 $result .=
'<table class="noborder nohover centpercent">';
221 $result .=
'<tr class="liste_titre">';
222 $result .=
'<td colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"Proposals").
'</td>';
225 foreach ($listofstatus as $status) {
226 $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
228 $colorseries[$status] =
'-'.$badgeStatus0;
231 $colorseries[$status] = $badgeStatus1;
234 $colorseries[$status] = $badgeStatus4;
237 $colorseries[$status] = $badgeStatus9;
240 $colorseries[$status] = $badgeStatus6;
243 if (empty($conf->use_javascript_ajax)) {
244 $result .=
'<tr class="oddeven">';
245 $result .=
'<td>'.$propalstatic->LibStatut($status, 0).
'</td>';
246 $result .=
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
247 $result .=
"</tr>\n";
251 if ($conf->use_javascript_ajax) {
253 $result .=
'<td align="center" colspan="2">';
255 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
257 $dolgraph->SetData($dataseries);
258 $dolgraph->SetDataColor(array_values($colorseries));
259 $dolgraph->setShowLegend(2);
260 $dolgraph->setShowPercent(1);
261 $dolgraph->SetType(array(
'pie'));
262 $dolgraph->setHeight(
'150');
263 $dolgraph->setWidth(
'300');
264 $dolgraph->draw(
'idgraphthirdparties');
265 $result .= $dolgraph->show($total ? 0 : 1);
279 $result .=
'<tr class="liste_total">';
280 $result .=
'<td>'.$langs->trans(
"Total").
'</td>';
281 $result .=
'<td class="right">'.$total.
'</td>';
284 $result .=
'</table>';