diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 32732931e73..1ed0b684696 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -1,11 +1,11 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2020 Pierre Ardoin - * Copyright (C) 2020 Tobias Sekan +/* Copyright (C) 2001-2005 Rodolphe Quiedeville + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2020 Tobias Sekan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,31 +22,31 @@ */ /** - * \file htdocs/comm/index.php - * \ingroup commercial - * \brief Home page of commercial area + * \file htdocs/comm/index.php + * \ingroup commercial + * \brief Home page of commercial area */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (!empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; -if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; if (!$user->rights->societe->lire) accessforbidden(); -$hookmanager = new HookManager($db); +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager = new HookManager($db); $hookmanager->initHooks(array('commercialindex')); // Load translation files required by the page -$langs->loadLangs(array("commercial", "propal")); +$langs->loadLangs(array("boxes", "commercial", "contracts", "orders", "propal", "supplier_proposal")); $action = GETPOST('action', 'aZ09'); $bid = GETPOST('bid', 'int'); @@ -84,7 +84,8 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial'); print '
'; -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo +// This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // Search proposal if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); @@ -136,19 +137,14 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless * Draft customer proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $langs->load("propal"); - - $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.email"; - $sql .= ", s.entity"; - $sql .= ", s.code_compta"; + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc"; + $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_statut = 0"; + $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; @@ -157,7 +153,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $total = 0; $num = $db->num_rows($resql); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); + startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num); if ($num > 0) { $i = 0; @@ -185,11 +181,11 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { print ''; print ''.$propalstatic->getNomUrl(1).''; print ''.$companystatic->getNomUrl(1, 'customer', 16).''; - print ''.price($obj->total_ht).''; + print ''.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).''; print ''; $i++; - $total += $obj->total_ht; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } } @@ -206,28 +202,23 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { * Draft supplier proposals */ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { - $langs->load("supplier_proposal"); - - $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc"; + $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.entity, s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_statut = 0"; + $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")"; + $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT; $sql .= " AND p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($socid) $sql .= " AND s.rowid = ".$socid; $resql = $db->query($sql); if ($resql) { $total = 0; $num = $db->num_rows($resql); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); + startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=".SupplierProposal::STATUS_DRAFT, 2, $num); if ($num > 0) { $i = 0; @@ -251,13 +242,13 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $companystatic->email = $obj->email; print ''; - print ''.$supplierproposalstatic->getNomUrl(1).''; + print ''.$supplierproposalstatic->getNomUrl(1).''; print ''.$companystatic->getNomUrl(1, 'supplier', 16).''; - print ''.price($obj->total_ht).''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; print ''; $i++; - $total += $obj->total_ht; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } } @@ -274,28 +265,23 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa * Draft customer orders */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - $langs->load("orders"); - - $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.email"; - $sql .= ", s.entity"; - $sql .= ", s.code_compta"; + $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc"; + $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.fk_statut = 0"; - $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; + $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT; + $sql .= " AND c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; $resql = $db->query($sql); if ($resql) { $total = 0; $num = $db->num_rows($resql); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - startSimpleTable("DraftOrders", "commande/list.php", "search_status=0", 2, $num); + startSimpleTable("DraftOrders", "commande/list.php", "search_status=".Commande::STATUS_DRAFT, 2, $num); if ($num > 0) { $i = 0; @@ -326,7 +312,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { print ''; $i++; - $total += $obj->total_ttc; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } } @@ -343,28 +329,23 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { * Draft suppliers orders */ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { - $langs->load("orders"); - - $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc"; + $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.entity, s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE cf.fk_soc = s.rowid"; - $sql .= " AND cf.fk_statut = 0"; - $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; + $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")"; + $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT; + $sql .= " AND cf.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND cf.fk_soc = ".$socid; + if ($socid) $sql .= " AND cf.fk_soc = ".$socid; $resql = $db->query($sql); if ($resql) { $total = 0; $num = $db->num_rows($resql); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); + startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=".CommandeFournisseur::STATUS_DRAFT, 2, $num); if ($num > 0) { $i = 0; @@ -395,7 +376,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; $i++; - $total += $obj->total_ttc; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } } @@ -407,27 +388,20 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU } } -print '
'; - -$max = 3; +print '
'; +print '
'; /* * Last modified customers or prospects */ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { - $langs->load("boxes"); - - $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_compta"; - $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas, s.code_client, s.code_compta, s.entity, s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE s.client IN (1, 2, 3)"; - $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; + $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; + $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = $socid"; + if ($socid) $sql .= " AND s.rowid = $socid"; $sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); @@ -485,18 +459,13 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { * Last suppliers */ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) { - $langs->load("boxes"); - - $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm, s.code_fournisseur, s.entity, s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE s.fournisseur = 1"; - $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; + $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; + $sql .= " AND s.fournisseur = ".Societe::SUPPLIER; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY s.datec DESC"; $sql .= $db->plimit($max, 0); @@ -556,21 +525,18 @@ if ($user->rights->agenda->myactions->read) { * Latest contracts */ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT - $langs->load("contracts"); + $staticcontrat = new Contrat($db); - $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; - $sql .= ", s.code_client"; - $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql = "SELECT s.nom as name, s.rowid, s.canvas, s.code_client, s.entity, s.email"; $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('contract').")"; + $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")"; + $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.fk_product = p.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit(5, 0); @@ -582,7 +548,6 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T if ($num > 0) { $i = 0; - $staticcontrat = new Contrat($db); while ($i < $num) { $obj = $db->fetch_object($resql); @@ -615,21 +580,17 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T /* - * Opened proposals + * Opened (validated) proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $langs->load("propal"); - - $sql = "SELECT s.nom as name, s.rowid, s.code_client"; - $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + $sql = "SELECT p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql .= ", s.nom as name, s.rowid, s.code_client, s.entity, s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('propal').")"; - $sql .= " AND p.fk_statut = 1"; + $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY p.rowid DESC"; @@ -663,24 +624,21 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $companystatic->entity = $obj->entity; $companystatic->email = $obj->email; - print ''; - - // Ref - print ''; - print ''; - print ''; - print ''; - print '
'; - print $propalstatic->getNomUrl(1); - print ''; - if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); - print ''; $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); - print '
'; - print ""; + $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$propalstatic->getNomUrl(1).''.$warning.''.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'
'; + print ''; print ''.$companystatic->getNomUrl(1, 'customer', 44).''; print ''.dol_print_date($db->jdate($obj->dp), 'day').''; @@ -690,7 +648,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { print ''; $i++; - $total += $obj->total_ttc; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } } @@ -704,21 +662,17 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { /* - * Opened Order + * Opened (validated) order */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - $langs->load("orders"); - - $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; - $sql .= ", s.code_client"; - $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; + $sql .= ", s.nom as name, s.rowid, s.code_client, s.entity, s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('commande').")"; - $sql .= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")"; + $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY c.rowid DESC"; @@ -728,7 +682,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $total = 0; $num = $db->num_rows($resql); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - startSimpleTable("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); + startSimpleTable("OrdersOpened", "commande/list.php", "search_status=".Commande::STATUS_VALIDATED, 4, $num); if ($num > 0) { $i = 0; @@ -752,33 +706,31 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $companystatic->entity = $obj->entity; $companystatic->email = $obj->email; - print ''; - - // Ref - print ''; - print ''; - print ''; - print ''; - print '
'; - print $orderstatic->getNomUrl(1); - print ''; - //if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); - print ''; $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; - print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir); - print '
'; - print ""; + //$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$orderstatic->getNomUrl(1).''.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).'
'; + print ''; print ''.$companystatic->getNomUrl(1, 'customer', 44).''; print ''.dol_print_date($db->jdate($obj->dp), 'day').''; print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''; - print ''."\n"; + + print ''; $i++; - $total += $obj->total_ttc; + $total +=(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } } @@ -790,7 +742,9 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { } } -print '
'; +print '
'; +print ''; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 9e138c52cbe..692f561867a 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2019 Nicolas ZABOURI +/* Copyright (C) 2003-2004 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2020 Tobias Sekan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,22 +20,12 @@ */ /** - * \file htdocs/comm/propal/index.php - * \ingroup propal - * \brief Home page of proposal area + * \file htdocs/comm/propal/index.php + * \ingroup propal + * \brief Home page of proposal area */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - -$hookmanager = new HookManager($db); - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('proposalindex')); - -// Load translation files required by the page -$langs->loadLangs(array('propal', 'companies')); // Security check $socid = GETPOST('socid', 'int'); @@ -43,13 +34,24 @@ if (isset($user->socid) && $user->socid > 0) $action = ''; $socid = $user->socid; } -$result = restrictedArea($user, 'propal'); +restrictedArea($user, 'propal'); +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('proposalindex')); + +// Load translation files required by the page +$langs->loadLangs(array('propal', 'companies')); + +$now = dol_now(); +$max = 5; /* * View */ -$now = dol_now(); $propalstatic = new Propal($db); $companystatic = new Societe($db); $form = new Form($db); @@ -60,192 +62,218 @@ llxHeader("", $langs->trans("ProspectionArea"), $help_url); print load_fiche_titre($langs->trans("ProspectionArea"), '', 'propal'); -//print ''; -//print ''; + print ''; + print ''; + } + + //if ($totalinprocess != $total) + //{ + // print ''; + // print ''; + // print ''; + // print ''; + //} + + print ''; + print ''; + print ''; + print ''; + + print '
'; -print '
'; +print '
'; +print '
'; - -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +// This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { - print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print "
'.$langs->trans("Search").'
'; - print $langs->trans("Proposal").':

\n"; -} + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Search").'
'.$langs->trans("Proposal").':
'; + print '
'; + print '
'; + print '
'; +} /* * Statistics */ +$listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED); $sql = "SELECT count(p.rowid) as nb, p.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql .= " WHERE p.fk_soc = s.rowid"; -$sql .= " AND p.entity IN (".getEntity('propal').")"; +$sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; +$sql .= " AND p.fk_soc = s.rowid"; if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -$sql .= " AND p.fk_statut IN (0,1,2,3,4)"; +$sql .= " AND p.fk_statut IN (".implode(" ,", $listofstatus).")"; $sql .= " GROUP BY p.fk_statut"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $colorseries = array(); + $vals = array(); - $total = 0; - $totalinprocess = 0; - $dataseries = array(); - $colorseries = array(); - $vals = array(); + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $vals[$obj->status] = $obj->nb; + $totalinprocess += $obj->nb; - // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - $vals[$obj->status] = $obj->nb; - $totalinprocess += $obj->nb; + $total += $obj->nb; + } + $i++; + } + $db->free($resql); - $total += $obj->nb; - } - $i++; - } - $db->free($resql); + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + print '
'; + print ''; - print '
'; - print '
'; - print ''."\n"; - $listofstatus = array(0, 1, 2, 3, 4); - foreach ($listofstatus as $status) - { - $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4; - if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9; - if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6; + print ''; + print ''; + print ''; - if (empty($conf->use_javascript_ajax)) - { - print ''; - print ''; - print ''; - print "\n"; - } - } - if ($conf->use_javascript_ajax) - { - print ''; + print ''; + print ''; + print "\n"; + } + } - print ''; - } - //if ($totalinprocess != $total) - //print ''; - print ''; - print "
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$propalstatic->LibStatut($status, 0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'; + foreach ($listofstatus as $status) { + $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; + if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; + if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4; + if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9; + if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphthirdparties'); - print $dolgraph->show($total ? 0 : 1); + if (empty($conf->use_javascript_ajax)) { + print '
'.$propalstatic->LibStatut($status, 0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')'.$totalinprocess.'
'.$langs->trans("Total").''.$total.'

"; + if ($conf->use_javascript_ajax) { + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphthirdparties'); + print $dolgraph->show($total ? 0 : 1); + + print '
'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')'.$totalinprocess.'
'.$langs->trans("Total").''.$total.'
'; + print ''; + print '
'; } else { - dol_print_error($db); + dol_print_error($db); } /* * Draft proposals */ -if (!empty($conf->propal->enabled)) -{ - $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; +if (!empty($conf->propal->enabled)) { + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc"; + $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('propal').")"; - $sql .= " AND c.fk_statut = 0"; - if ($socid) $sql .= " AND c.fk_soc = ".$socid; + $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.fk_statut =".Propal::STATUS_DRAFT; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND p.fk_soc = ".$socid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { - print '
'; - print ''; - print ''; - $langs->load("propal"); - print ''; + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("DraftPropals", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num); + if ($num) { + $total = 0; $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { + + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - print ''; $propalstatic->id = $obj->rowid; $propalstatic->ref = $obj->ref; - print ''; + $propalstatic->ref_client = $obj->ref_client; + $propalstatic->total_ht = $obj->total_ht; + $propalstatic->total_tva = $obj->total_tva; + $propalstatic->total_ttc = $obj->total_ttc; $companystatic->id = $obj->socid; - $companystatic->name = $obj->socname; + $companystatic->name = $obj->name; $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; - print ''; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; + $companystatic->code_compta = $obj->code_compta; + print ''; + print ''; + print ''; + print ''; print ''; + $i++; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - print "
'.$langs->trans("DraftPropals").' '.$num.'
'.$propalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 24).'
'.$propalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 16).''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
"; - print "

"; } + + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); } } +print ''; -//print ''; -print '
'; - - -$max = 5; +print '
'; +print '
'; /* * Last modified proposals */ -$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; -$sql .= " date_cloture as datec"; +$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, date_cloture as datec"; +$sql .= ", s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql .= " WHERE c.fk_soc = s.rowid"; -$sql .= " AND c.entity IN (".getEntity('propal').")"; +$sql .= " WHERE c.entity IN (".getEntity($propalstatic->element).")"; +$sql .= " AND c.fk_soc = s.rowid"; //$sql.= " AND c.fk_statut > 2"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -253,150 +281,126 @@ $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ - print '
'; - print ''; - print ''; - print ''; - +if ($resql) { $num = $db->num_rows($resql); - if ($num) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + startSimpleTable($langs->trans("LastModifiedProposals", $max), "", "", 3); - print ''; - print ''; - $companystatic->id = $obj->socid; $companystatic->name = $obj->socname; $companystatic->client = $obj->client; $companystatic->canvas = $obj->canvas; - print ''; - print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + + print ''; + $i++; } } - print "
'.$langs->trans("LastModifiedProposals", $max).'
'; + if ($num) { + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); $propalstatic->id = $obj->rowid; $propalstatic->ref = $obj->ref; - print ''; - print ''; - - print ''; - - print '
'; - print $propalstatic->getNomUrl(1); - print ''; - print ' '; - print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); - print '
'; - - print '
'.$companystatic->getNomUrl(1, 'customer').''.dol_print_date($db->jdate($obj->datec), 'day').''.$propalstatic->LibStatut($obj->fk_statut, 3).'
'; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; + print '
'.$propalstatic->getNomUrl(1).''.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'
'; + print '
'.$companystatic->getNomUrl(1, 'customer').''.dol_print_date($db->jdate($obj->datec), 'day').''.$propalstatic->LibStatut($obj->fk_statut, 3).'
"; - print "

"; -} else dol_print_error($db); + + finishSimpleTable(true); + $db->free($resql); +} else { + dol_print_error($db); +} /* - * Open proposals + * Open (validated) proposals */ -if (!empty($conf->propal->enabled) && $user->rights->propale->lire) -{ - $langs->load("propal"); - - $now = dol_now(); - +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('propal').")"; - $sql .= " AND p.fk_statut = 1"; + $sql .= " AND p.entity IN (".getEntity($propalstatic->element).")"; + $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY p.rowid DESC"; - $result = $db->query($sql); - if ($result) - { + $resql = $db->query($sql); + if ($resql) { $total = 0; - $num = $db->num_rows($result); - $i = 0; - if ($num > 0) - { - print '
'; - print ''; - print ''; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=".Propal::STATUS_VALIDATED, 4, $num); - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($result); - - print ''; - - // Ref - print '"; - $companystatic->id = $obj->socid; $companystatic->name = $obj->socname; $companystatic->client = $obj->client; $companystatic->canvas = $obj->canvas; - print ''."\n"; - print ''."\n"; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; - print ''; + $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : ''; + + print ''; + + // Ref + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; - print ''."\n"; - print ''."\n"; $i++; - $total += $obj->total_ttc; + $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); } - if ($num > $nbofloop) - { - print '"; - } elseif ($total > 0) - { - print '"; - } - print "
'.$langs->trans("ProposalsOpened").' '.$num.'
'; + if ($num > 0) { + $i = 0; + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); $propalstatic->id = $obj->propalid; $propalstatic->ref = $obj->ref; - print ''; - print ''; - print ''; - print '
'; - print $propalstatic->getNomUrl(1); - print ''; - if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); - print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); - print '
'; - - print "
'.$companystatic->getNomUrl(1, 'customer', 44).''.dol_print_date($db->jdate($obj->dp), 'day').''.price($obj->total_ttc).'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$propalstatic->getNomUrl(1).''.$warning.''.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'
'; + print '
'.$companystatic->getNomUrl(1, 'customer', 44).''.dol_print_date($db->jdate($obj->dp), 'day').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut, 3).'
'.$propalstatic->LibStatut($obj->fk_statut, 3).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
"; - print "

"; } + + addSummaryTableLine(5, $num, $nbofloop, $total, "None", true); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } @@ -405,6 +409,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) /* * Proposals to process */ + /* if (! empty($conf->propal->enabled)) { @@ -479,7 +484,9 @@ if (! empty($conf->propal->enabled)) /* * Proposal that are in a shipping process */ -/*if (! empty($conf->propal->enabled)) + +/* +if (! empty($conf->propal->enabled)) { $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; @@ -548,8 +555,9 @@ if (! empty($conf->propal->enabled)) } */ -//print ''; -print '
'; +print '
'; +print ''; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardPropals', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bdff8ce4063..afec889163f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -82,6 +82,12 @@ function getEntity($element, $shared = 1, $currentobject = null) { global $conf, $mc; + // fix different element names (France to English) + switch ($element) { + case 'contrat': $element = 'contract'; break; // "/contrat/class/contrat.class.php" + case 'order_supplier': $element = 'supplier_order'; break; // "/fourn/class/fournisseur.commande.class.php" + } + if (is_object($mc)) { return $mc->getEntity($element, $shared, $currentobject); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 61c958ed89b..4f41326b175 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -713,6 +713,35 @@ class Societe extends CommonObject */ public $bank_account; + /** + * Third party is no customer + */ + const NO_CUSTOMER = 0; + + /** + * Third party is a customer + */ + const CUSTOMER = 1; + + /** + * Third party is a prospect + */ + const PROSPECT = 2; + + /** + * Third party is a customer and a prospect + */ + const CUSTOMER_AND_PROSPECT = 3; + + /** + * Third party is no supplier + */ + const NO_SUPPLIER = 0; + + /** + * Third party is a supplier + */ + const SUPPLIER = 1; /** * Constructor