37 $langs->loadLangs(array(
'propal',
'compta',
'companies'));
42 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/propal/card.php', [
'id' =>
$object->id]);
43 $head[$h][1] = $langs->trans(
'Proposal');
44 $head[$h][2] =
'comm';
48 || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'lire'))))) {
49 $langs->load(
"sendings");
51 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/expedition/propal.php', [
'id' =>
$object->id]);
53 $text = $langs->trans(
"Shipment");
59 $text .= $langs->trans(
"Receivings");
62 $head[$h][2] =
'shipping';
67 $nbContact = count(
$object->liste_contact(-1,
'internal')) + count(
$object->liste_contact(-1,
'external'));
68 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/propal/contact.php', [
'id' =>
$object->id]);
69 $head[$h][1] = $langs->trans(
'ContactsAddresses');
71 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
73 $head[$h][2] =
'contact';
85 if (!empty(
$object->note_private)) {
88 if (!empty(
$object->note_public)) {
91 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/propal/note.php', [
'id' =>
$object->id]);
92 $head[$h][1] = $langs->trans(
'Notes');
94 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
96 $head[$h][2] =
'note';
100 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
101 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
103 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
105 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/propal/document.php', [
'id' =>
$object->id]);
106 $head[$h][1] = $langs->trans(
'Documents');
107 if (($nbFiles + $nbLinks) > 0) {
108 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
110 $head[$h][2] =
'document';
114 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/propal/agenda.php', [
'id' =>
$object->id]);
115 $head[$h][1] = $langs->trans(
"Events");
116 if (
isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
119 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
120 $cachekey =
'count_events_propal_'.$object->id;
122 if (!is_null($dataretrieved)) {
123 $nbEvent = $dataretrieved;
125 $sql =
"SELECT COUNT(id) as nb";
126 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
127 $sql .=
" WHERE fk_element = ".((int)
$object->id);
128 $sql .=
" AND elementtype = 'propal'";
129 $resql =
$db->query($sql);
131 $obj =
$db->fetch_object($resql);
134 dol_syslog(
'Failed to count actioncomm '.
$db->lasterror(), LOG_ERR);
140 $head[$h][1] .= $langs->trans(
"Agenda");
142 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
145 $head[$h][2] =
'agenda';
162 global $langs,
$conf, $extrafields;
164 $extrafields->fetch_name_optionals_label(
'propal');
165 $extrafields->fetch_name_optionals_label(
'propaldet');
170 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/propal.php');
171 $head[$h][1] = $langs->trans(
"Miscellaneous");
172 $head[$h][2] =
'general';
181 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/admin/propal_extrafields.php');
182 $head[$h][1] = $langs->trans(
"ExtraFields");
183 $nbExtrafields = $extrafields->attributes[
'propal'][
'count'];
184 if ($nbExtrafields > 0) {
185 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
187 $head[$h][2] =
'attributes';
190 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/comm/admin/propaldet_extrafields.php');
191 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
192 $nbExtrafields = $extrafields->attributes[
'propaldet'][
'count'];
193 if ($nbExtrafields > 0) {
194 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
196 $head[$h][2] =
'attributeslines';
214 global
$conf,
$db, $langs, $user, $hookmanager;
218 if (!
isModEnabled(
'propal') || !$user->hasRight(
'propal',
'lire')) {
225 if ($user->socid > 0) $socid = $user->socid;
226 $sql =
"SELECT count(p.rowid) as nb, p.fk_statut as status";
227 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
228 $sql .=
", ".MAIN_DB_PREFIX.
"propal as p";
229 if ($user->socid == 0 && !$user->hasRight(
'societe',
'client',
'voir')) {
230 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
232 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
233 $sql .=
" AND p.fk_soc = s.rowid";
235 $sql .=
' AND p.fk_soc = '.((int) $user->socid);
237 if ($user->socid == 0 && !$user->hasRight(
'societe',
'client',
'voir')) {
238 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
240 $sql .=
" AND p.fk_statut IN (".$db->sanitize(implode(
" ,", $listofstatus)).
")";
242 $parameters = array(
'socid' => $user->socid);
243 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
244 $sql .= $hookmanager->resPrint;
245 $sql .=
" GROUP BY p.fk_statut";
246 $resql =
$db->query($sql);
248 $num =
$db->num_rows($resql);
252 $dataseries = array();
253 $colorseries = array();
257 $obj =
$db->fetch_object($resql);
259 $vals[$obj->status] = $obj->nb;
260 $totalinprocess += $obj->nb;
268 global $badgeStatus0, $badgeStatus1, $badgeStatus4, $badgeStatus6, $badgeStatus9;
269 include DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
271 $result =
'<div class="div-table-responsive-no-min">';
272 $result .=
'<table class="noborder nohover centpercent">';
274 $result .=
'<tr class="liste_titre">';
275 $result .=
'<td colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"Proposals").
'</td>';
278 foreach ($listofstatus as $status) {
279 $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
281 $colorseries[$status] =
'-'.$badgeStatus0;
284 $colorseries[$status] = $badgeStatus1;
287 $colorseries[$status] = $badgeStatus4;
290 $colorseries[$status] = $badgeStatus9;
293 $colorseries[$status] = $badgeStatus6;
296 if (empty(
$conf->use_javascript_ajax)) {
297 $result .=
'<tr class="oddeven">';
298 $result .=
'<td>'.$propalstatic->LibStatut($status, 0).
'</td>';
299 $result .=
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
300 $result .=
"</tr>\n";
304 if (
$conf->use_javascript_ajax) {
306 $result .=
'<td align="center" colspan="2">';
308 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
310 $dolgraph->SetData($dataseries);
311 $dolgraph->SetDataColor(array_values($colorseries));
312 $dolgraph->setShowLegend(2);
313 $dolgraph->setShowPercent(1);
314 $dolgraph->SetType(array(
'pie'));
315 $dolgraph->setHeight(
'150');
316 $dolgraph->setWidth(
'300');
317 $dolgraph->draw(
'idgraphthirdparties');
318 $result .= $dolgraph->show($total ? 0 : 1);
332 $result .=
'<tr class="liste_total">';
333 $result .=
'<td>'.$langs->trans(
"Total").
'</td>';
334 $result .=
'<td class="right">'.$total.
'</td>';
337 $result .=
'</table>';
if(! $sortfield) if(! $sortorder) $object
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage proposals.
const STATUS_DRAFT
Draft status.
const STATUS_SIGNED
Signed quote.
const STATUS_NOTSIGNED
Not signed quote.
const STATUS_BILLED
Billed or processed quote.
const STATUS_VALIDATED
Validated status.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_setcache($memoryid, $data, $expire=0, $filecache=0, $replace=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
propal_admin_prepare_head()
Return array head with list of tabs to view object information.
getCustomerProposalPieChart($socid=0)
Return a HTML table that contains a pie chart of customer proposals.
propal_prepare_head($object)
Prepare array with list of tabs.