Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
05636c39bd
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
|
||||
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
|
||||
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
|
||||
*
|
||||
* 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 '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
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 '<tr class="oddeven">';
|
||||
print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 16).'</td>';
|
||||
print '<td class="nowrap right">'.price($obj->total_ht).'</td>';
|
||||
print '<td class="nowrap right">'.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$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 '<tr class="oddeven">';
|
||||
print '<td class="nowrap">'.$supplierproposalstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="nowrap">'.$supplierproposalstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'supplier', 16).'</td>';
|
||||
print '<td class="nowrap right">'.price($obj->total_ht).'</td>';
|
||||
print '<td class="nowrap right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$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 '</tr>';
|
||||
|
||||
$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 '</tr>';
|
||||
|
||||
$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 '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
$max = 3;
|
||||
print '</div><div class="fichetwothirdright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
|
||||
/*
|
||||
* 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 '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" width="140">';
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td class="nobordernopadding nowrap">';
|
||||
print $propalstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td width="18" class="nobordernopadding nowrap">';
|
||||
if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
print '</td>';
|
||||
print '<td width="16" align="center" class="nobordernopadding">';
|
||||
$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 '</td></tr></table>';
|
||||
print "</td>";
|
||||
$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td class="nowrap" width="140">';
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).'</td>';
|
||||
print '<td width="18" class="nobordernopadding nowrap">'.$warning.'</td>';
|
||||
print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '</td>';
|
||||
|
||||
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
|
||||
print '<td class="right">'.dol_print_date($db->jdate($obj->dp), 'day').'</td>';
|
||||
@ -690,7 +648,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
|
||||
print '</tr>';
|
||||
|
||||
$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 '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" width="140">';
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td class="nobordernopadding nowrap">';
|
||||
print $orderstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td width="18" class="nobordernopadding nowrap">';
|
||||
//if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
print '</td>';
|
||||
print '<td width="16" align="center" class="nobordernopadding">';
|
||||
$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 '</td></tr></table>';
|
||||
print "</td>";
|
||||
//$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td class="nowrap" width="140">';
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td class="nobordernopadding nowrap">'.$orderstatic->getNomUrl(1).'</td>';
|
||||
print '<td width="18" class="nobordernopadding nowrap"></td>';
|
||||
print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).'</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '</td>';
|
||||
|
||||
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
|
||||
print '<td class="right">'.dol_print_date($db->jdate($obj->dp), 'day').'</td>';
|
||||
print '<td class="right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
|
||||
print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
print '</tr>';
|
||||
|
||||
$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 '</div></div></div>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
$parameters = array('user' => $user);
|
||||
$reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
|
||||
*
|
||||
* 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 '<table width="100%" class="notopnoleftnoright">';
|
||||
//print '<tr><td valign="top" width="30%" class="notopnoleft">';
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichethirdleft">';
|
||||
|
||||
|
||||
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 '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("Proposal").':</td><td><input type="text" class="flat" name="sall" size=18></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
|
||||
print "</table></div></form><br>\n";
|
||||
}
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">'.$langs->trans("Search").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("Proposal").':</td>';
|
||||
print '<td><input type="text" class="flat" name="sall" size=18></td>';
|
||||
print '<td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'</td></tr>'."\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 '<tr class="liste_titre">';
|
||||
print '<td colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if (empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$propalstatic->LibStatut($status, 0).'</td>';
|
||||
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print '<tr><td align="center" colspan="2">';
|
||||
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 '<tr class="oddeven">';
|
||||
print '<td>'.$propalstatic->LibStatut($status, 0).'</td>';
|
||||
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
//if ($totalinprocess != $total)
|
||||
//print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td><td class="right">'.$totalinprocess.'</td></tr>';
|
||||
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">'.$total.'</td></tr>';
|
||||
print "</table></div><br>";
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print '<tr>';
|
||||
print '<td align="center" colspan="2">';
|
||||
|
||||
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 '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
//if ($totalinprocess != $total)
|
||||
//{
|
||||
// print '<tr class="liste_total">';
|
||||
// print '<td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td>';
|
||||
// print '<td class="right">'.$totalinprocess.'</td>';
|
||||
// print '</tr>';
|
||||
//}
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
print '<td>'.$langs->trans("Total").'</td>';
|
||||
print '<td class="right">'.$total.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
} 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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
$langs->load("propal");
|
||||
print '<td colspan="2">'.$langs->trans("DraftPropals").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?search_status=0"><span class="badge">'.$num.'</span></a></td></tr>';
|
||||
$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 '<tr class="oddeven">';
|
||||
|
||||
$propalstatic->id = $obj->rowid;
|
||||
$propalstatic->ref = $obj->ref;
|
||||
print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>';
|
||||
$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 '<td>'.$companystatic->getNomUrl(1, 'customer', 24).'</td>';
|
||||
$companystatic->entity = $obj->entity;
|
||||
$companystatic->email = $obj->email;
|
||||
$companystatic->code_compta = $obj->code_compta;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 16).'</td>';
|
||||
print '<td class="nowrap right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
$total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
|
||||
}
|
||||
if ($num > $nbofloop)
|
||||
{
|
||||
print '<tr class="liste_total"><td colspan="2" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
|
||||
} elseif ($total > 0)
|
||||
{
|
||||
print '<tr class="liste_total"><td class="right">'.$langs->trans("Total").'</td><td class="right">'.price($total)."</td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
print "</div><br>";
|
||||
}
|
||||
|
||||
addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
|
||||
finishSimpleTable(true);
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
//print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
|
||||
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
|
||||
$max = 5;
|
||||
print '<div class="fichetwothirdright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
|
||||
/*
|
||||
* 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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4">'.$langs->trans("LastModifiedProposals", $max).'</td></tr>';
|
||||
|
||||
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 '<tr class="oddeven">';
|
||||
print '<td width="20%" class="nowrap">';
|
||||
if ($num) {
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$propalstatic->id = $obj->rowid;
|
||||
$propalstatic->ref = $obj->ref;
|
||||
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td width="96" class="nobordernopadding nowrap">';
|
||||
print $propalstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
print '<td width="16" class="nobordernopadding nowrap">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
print '<td width="16" class="nobordernopadding right">';
|
||||
$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 '</td></tr></table>';
|
||||
|
||||
print '</td>';
|
||||
|
||||
$companystatic->id = $obj->socid;
|
||||
$companystatic->name = $obj->socname;
|
||||
$companystatic->client = $obj->client;
|
||||
$companystatic->canvas = $obj->canvas;
|
||||
print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
|
||||
|
||||
print '<td>'.dol_print_date($db->jdate($obj->datec), 'day').'</td>';
|
||||
$filename = dol_sanitizeFileName($obj->ref);
|
||||
$filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
|
||||
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
|
||||
|
||||
print '<td class="right">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td width="20%" class="nowrap">';
|
||||
print '<table class="nobordernopadding">';
|
||||
print '<tr class="nocellnopadd">';
|
||||
print '<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).'</td>';
|
||||
print '<td width="16" class="nobordernopadding nowrap"></td>';
|
||||
print '<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '</td>';
|
||||
|
||||
print '<td>'.$companystatic->getNomUrl(1, 'customer').'</td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->datec), 'day').'</td>';
|
||||
print '<td class="right">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print "</table>";
|
||||
print "</div><br>";
|
||||
} 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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?search_status=1"><span class="badge">'.$num.'</span></a></td></tr>';
|
||||
$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 '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" width="140">';
|
||||
if ($num > 0) {
|
||||
$i = 0;
|
||||
while ($i < $nbofloop) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$propalstatic->id = $obj->propalid;
|
||||
$propalstatic->ref = $obj->ref;
|
||||
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
print '<td class="nobordernopadding nowrap">';
|
||||
print $propalstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td width="18" class="nobordernopadding nowrap">';
|
||||
if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
print '</td>';
|
||||
print '<td width="16" align="center" class="nobordernopadding">';
|
||||
$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 '</td></tr></table>';
|
||||
|
||||
print "</td>";
|
||||
|
||||
$companystatic->id = $obj->socid;
|
||||
$companystatic->name = $obj->socname;
|
||||
$companystatic->client = $obj->client;
|
||||
$companystatic->canvas = $obj->canvas;
|
||||
print '<td class="left">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>'."\n";
|
||||
|
||||
print '<td class="right">'.dol_print_date($db->jdate($obj->dp), 'day').'</td>'."\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 '<td class="right">'.price($obj->total_ttc).'</td>';
|
||||
$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" width="140">';
|
||||
print '<table class="nobordernopadding">';
|
||||
print '<tr class="nocellnopadd">';
|
||||
print '<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).'</td>';
|
||||
print '<td width="18" class="nobordernopadding nowrap">'.$warning.'</td>';
|
||||
print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '</td>';
|
||||
|
||||
print '<td class="left">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
|
||||
print '<td class="right">'.dol_print_date($db->jdate($obj->dp), 'day').'</td>';
|
||||
print '<td class="right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
|
||||
print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>'."\n";
|
||||
print '</tr>'."\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 '<tr class="liste_total"><td colspan="5" class="right">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>";
|
||||
} elseif ($total > 0)
|
||||
{
|
||||
print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td> </td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
print "</div><br>";
|
||||
}
|
||||
|
||||
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 '</td></tr></table>';
|
||||
print '</div></div></div>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
$parameters = array('user' => $user);
|
||||
$reshook = $hookmanager->executeHooks('dashboardPropals', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
if (!empty($conf->categorie->enabled))
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
@ -63,6 +64,8 @@ $searchCategoryProductOperator = (GETPOST('search_category_product_operator', 'i
|
||||
$searchCategoryProductList = GETPOST('search_category_product_list', 'array');
|
||||
$search_tosell = GETPOST("search_tosell", 'int');
|
||||
$search_tobuy = GETPOST("search_tobuy", 'int');
|
||||
$search_country = GETPOST("search_country", 'int');
|
||||
$search_state = GETPOST("state_id", 'int');
|
||||
$fourn_id = GETPOST("fourn_id", 'int');
|
||||
$catid = GETPOST('catid', 'int');
|
||||
$search_tobatch = GETPOST("search_tobatch", 'int');
|
||||
@ -105,6 +108,7 @@ $object = new Product($db);
|
||||
$hookmanager->initHooks(array('productservicelist'));
|
||||
$extrafields = new ExtraFields($db);
|
||||
$form = new Form($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
@ -206,7 +210,9 @@ $arrayfields = array(
|
||||
'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service'), 'position'=>52),
|
||||
'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical), 'position'=>53),
|
||||
'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>60),
|
||||
'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400),
|
||||
'p.fk_country'=>array('label'=>$langs->trans("Country").' ('.$langs->trans("Country").')', 'checked'=>0, 'position'=>100),
|
||||
'p.fk_state'=>array('label'=>$langs->trans("State").' ('.$langs->trans("State").')', 'checked'=>0, 'position'=>101),
|
||||
'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400),
|
||||
'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401),
|
||||
'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402),
|
||||
'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0, 'position'=>403),
|
||||
@ -275,6 +281,8 @@ if (empty($reshook))
|
||||
$searchCategoryProductList = array();
|
||||
$search_tosell = "";
|
||||
$search_tobuy = "";
|
||||
$search_country = "";
|
||||
$search_state = "";
|
||||
$search_vatrate = "";
|
||||
$search_tobatch = '';
|
||||
//$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type.
|
||||
@ -326,7 +334,7 @@ $sql .= ' p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_
|
||||
$sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,';
|
||||
$sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,';
|
||||
$sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,';
|
||||
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units,';
|
||||
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, fk_country, fk_state,';
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ' p.fk_unit, cu.label as cu_label,';
|
||||
$sql .= ' MIN(pfp.unitprice) as minsellprice';
|
||||
if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
|
||||
@ -401,6 +409,8 @@ if ($searchCategoryProductOperator == 1) {
|
||||
}
|
||||
if ($fourn_id > 0) $sql .= " AND pfp.fk_soc = ".$fourn_id;
|
||||
if ($search_tobatch != '' && $search_tobatch >= 0) $sql .= " AND p.tobatch = ".$db->escape($search_tobatch);
|
||||
if ($search_country) $sql .= " AND p.fk_country = ".$search_country;
|
||||
if ($search_state) $sql .= " AND p.fk_state = ".$search_state;
|
||||
if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell);
|
||||
if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra);
|
||||
if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export);
|
||||
@ -418,7 +428,7 @@ $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.pric
|
||||
$sql .= " p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,";
|
||||
$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,';
|
||||
$sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.pmp, p.cost_price, p.stock,';
|
||||
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units';
|
||||
$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state';
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ', p.fk_unit, cu.label';
|
||||
|
||||
if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
|
||||
@ -498,6 +508,8 @@ if ($resql)
|
||||
if ($search_label) $param .= "&search_label=".urlencode($search_label);
|
||||
if ($search_tosell != '') $param .= "&search_tosell=".urlencode($search_tosell);
|
||||
if ($search_tobuy != '') $param .= "&search_tobuy=".urlencode($search_tobuy);
|
||||
if ($search_country != '') $param .= "&search_country=".urlencode($search_country);
|
||||
if ($search_state != '') $param .= "&search_state=".urlencode($search_state);
|
||||
if ($search_vatrate) $sql .= natural_search('p.tva_tx', $search_vatrate);
|
||||
if ($fourn_id > 0) $param .= ($fourn_id ? "&fourn_id=".$fourn_id : "");
|
||||
//if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):"");
|
||||
@ -819,6 +831,10 @@ if ($resql)
|
||||
if (!empty($arrayfields['stock_virtual']['checked'])) print '<td class="liste_titre"> </td>';
|
||||
// To batch
|
||||
if (!empty($arrayfields['p.tobatch']['checked'])) print '<td class="liste_titre center">'.$form->selectyesno($search_tobatch, '', '', '', 1).'</td>';
|
||||
// Country
|
||||
if (!empty($arrayfields['p.fk_country']['checked'])) print '<td class="liste_titre center">'.$form->select_country($search_country, 'search_country', '', 0).'</td>';
|
||||
// State
|
||||
if (!empty($arrayfields['p.fk_state']['checked'])) print '<td class="liste_titre center">'.$formcompany->select_state($search_state, $search_country).'</td>';
|
||||
// Accountancy code sell
|
||||
if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>';
|
||||
if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_intra" value="'.dol_escape_htmltag($search_accountancy_code_sell_intra).'"></td>';
|
||||
@ -945,6 +961,12 @@ if ($resql)
|
||||
if (!empty($arrayfields['p.tobatch']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"], "p.tobatch", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['p.fk_country']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.fk_country']['label'], $_SERVER["PHP_SELF"], "p.fk_country", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['p.fk_state']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.fk_state']['label'], $_SERVER["PHP_SELF"], "p.fk_state", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
@ -1414,6 +1436,18 @@ if ($resql)
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Country
|
||||
if (!empty($arrayfields['p.fk_country']['checked']))
|
||||
{
|
||||
print '<td>'.getCountry($obj->fk_country, 0, $db).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
// State
|
||||
if (!empty($arrayfields['p.fk_state']['checked']))
|
||||
{
|
||||
print '<td>'.getState($obj->fk_state, 0, $db).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Accountancy code sell
|
||||
if (!empty($arrayfields['p.accountancy_code_sell']['checked']))
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user