code syntax commande directory

This commit is contained in:
Frédéric FRANCE 2021-02-23 20:46:19 +01:00
parent 2642e1d1b3
commit 6dfca9f1f5
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
13 changed files with 2140 additions and 1748 deletions

File diff suppressed because it is too large Load Diff

View File

@ -165,28 +165,37 @@ class Orders extends DolibarrApi
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id;
}
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
$sql .= " FROM ".MAIN_DB_PREFIX."commande as t"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
}
$sql .= ' WHERE t.entity IN ('.getEntity('commande').')'; $sql .= ' WHERE t.entity IN ('.getEntity('commande').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; $sql .= " AND t.fk_soc = sc.fk_soc";
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale }
if ($socids) {
$sql .= " AND t.fk_soc IN (".$socids.")";
}
if ($search_sale > 0) {
$sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
}
// Insert sale filter // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0) {
{
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -195,8 +204,7 @@ class Orders extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0) {
{
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
@ -207,13 +215,11 @@ class Orders extends DolibarrApi
dol_syslog("API Rest request"); dol_syslog("API Rest request");
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0; $i = 0;
while ($i < $min) while ($i < $min) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$commande_static = new Commande($this->db); $commande_static = new Commande($this->db);
if ($commande_static->fetch($obj->rowid)) { if ($commande_static->fetch($obj->rowid)) {
@ -613,18 +619,20 @@ class Orders extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') {
continue;
}
$this->commande->$field = $value; $this->commande->$field = $value;
} }
// Update availability // Update availability
if (!empty($this->commande->availability_id)) { if (!empty($this->commande->availability_id)) {
if ($this->commande->availability($this->commande->availability_id) < 0) if ($this->commande->availability($this->commande->availability_id) < 0) {
throw new RestException(400, 'Error while updating availability'); throw new RestException(400, 'Error while updating availability');
} }
}
if ($this->commande->update(DolibarrApiAccess::$user) > 0) if ($this->commande->update(DolibarrApiAccess::$user) > 0) {
{
return $this->get($id); return $this->get($id);
} else { } else {
throw new RestException(500, $this->commande->error); throw new RestException(500, $this->commande->error);
@ -979,8 +987,9 @@ class Orders extends DolibarrApi
{ {
$commande = array(); $commande = array();
foreach (Orders::$FIELDS as $field) { foreach (Orders::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field])) {
throw new RestException(400, $field." field missing"); throw new RestException(400, $field." field missing");
}
$commande[$field] = $data[$field]; $commande[$field] = $data[$field];
} }
return $commande; return $commande;

File diff suppressed because it is too large Load Diff

View File

@ -70,16 +70,14 @@ class CommandeStats extends Stats
$this->cachefilesuffix = $mode; $this->cachefilesuffix = $mode;
$this->join = ''; $this->join = '';
if ($mode == 'customer') if ($mode == 'customer') {
{
$object = new Commande($this->db); $object = new Commande($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from = MAIN_DB_PREFIX.$object->table_element." as c";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
$this->field = 'total_ht'; $this->field = 'total_ht';
$this->field_line = 'total_ht'; $this->field_line = 'total_ht';
//$this->where .= " c.fk_statut > 0"; // Not draft and not cancelled //$this->where .= " c.fk_statut > 0"; // Not draft and not cancelled
} elseif ($mode == 'supplier') } elseif ($mode == 'supplier') {
{
$object = new CommandeFournisseur($this->db); $object = new CommandeFournisseur($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from = MAIN_DB_PREFIX.$object->table_element." as c";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
@ -90,21 +88,22 @@ class CommandeStats extends Stats
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where .= ($this->where ? ' AND ' : '').'c.entity IN ('.getEntity('commande').')'; $this->where .= ($this->where ? ' AND ' : '').'c.entity IN ('.getEntity('commande').')';
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if (!$user->rights->societe->client->voir && !$this->socid) {
if ($this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
{ }
if ($this->socid) {
$this->where .= " AND c.fk_soc = ".$this->socid; $this->where .= " AND c.fk_soc = ".$this->socid;
} }
if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; if ($this->userid > 0) {
$this->where .= ' AND c.fk_user_author = '.$this->userid;
}
if ($typentid) if ($typentid) {
{
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc';
$this->where .= ' AND s.fk_typent = '.$typentid; $this->where .= ' AND s.fk_typent = '.$typentid;
} }
if ($categid) if ($categid) {
{
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc';
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie';
$this->where .= ' AND cat.rowid = '.$categid; $this->where .= ' AND cat.rowid = '.$categid;
@ -124,7 +123,9 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb"; $sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join; $sql .= $this->join;
$sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where; $sql .= " AND ".$this->where;
@ -147,7 +148,9 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join; $sql .= $this->join;
$sql .= " WHERE ".$this->where; $sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
@ -169,7 +172,9 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")"; $sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join; $sql .= $this->join;
$sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where; $sql .= " AND ".$this->where;
@ -192,7 +197,9 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")"; $sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join; $sql .= $this->join;
$sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where; $sql .= " AND ".$this->where;
@ -213,7 +220,9 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg";
$sql .= " FROM ".$this->from; $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join; $sql .= $this->join;
$sql .= " WHERE ".$this->where; $sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year"; $sql .= " GROUP BY year";
@ -235,7 +244,9 @@ class CommandeStats extends Stats
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
$sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join; $sql .= $this->join;
$sql .= " WHERE ".$this->where; $sql .= " WHERE ".$this->where;
$sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; $sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid";

View File

@ -41,7 +41,9 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'commande', $id, ''); $result = restrictedArea($user, 'commande', $id, '');
$object = new Commande($db); $object = new Commande($db);
@ -50,51 +52,39 @@ $object = new Commande($db);
* Ajout d'un nouveau contact * Ajout d'un nouveau contact
*/ */
if ($action == 'addcontact' && $user->rights->commande->creer) if ($action == 'addcontact' && $user->rights->commande->creer) {
{
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0 && $id > 0) if ($result > 0 && $id > 0) {
{
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
{
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} } elseif ($action == 'swapstatut' && $user->rights->commande->creer) {
// bascule du statut d'un contact
// bascule du statut d'un contact if ($object->fetch($id)) {
elseif ($action == 'swapstatut' && $user->rights->commande->creer)
{
if ($object->fetch($id))
{
$result = $object->swapContactStatus(GETPOST('ligne')); $result = $object->swapContactStatus(GETPOST('ligne'));
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} } elseif ($action == 'deletecontact' && $user->rights->commande->creer) {
// Efface un contact
// Efface un contact
elseif ($action == 'deletecontact' && $user->rights->commande->creer)
{
$object->fetch($id); $object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]); $result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
@ -147,12 +137,10 @@ if ($id > 0 || !empty($ref)) {
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer) if ($user->rights->commande->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
@ -190,10 +178,11 @@ if ($id > 0 || !empty($ref)) {
// Contacts lines (modules that overwrite templates must declare this into descriptor) // Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir) foreach ($dirtpls as $reldir) {
{
$res = @include dol_buildpath($reldir.'/contacts.tpl.php'); $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break; if ($res) {
break;
}
} }
} else { } else {
// Contact not found // Contact not found

View File

@ -33,14 +33,14 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
// Secrutiy check // Secrutiy check
if ($user->socid > 0) if ($user->socid > 0) {
{
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
if (!$user->rights->facture->creer) if (!$user->rights->facture->creer) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("companies", "orders")); $langs->loadLangs(array("companies", "orders"));
@ -49,12 +49,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "nom"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "nom";
}
/* /*
@ -71,25 +77,34 @@ $thirdpartystatic = new Societe($db);
$sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea"; $sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea";
$sql .= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta "; $sql .= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta ";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid"; $sql .= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid";
$sql .= " AND s.entity IN (".getEntity('societe').")"; $sql .= " AND s.entity IN (".getEntity('societe').")";
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) {
if (dol_strlen($stcomm)) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
{ }
if (dol_strlen($stcomm)) {
$sql .= " AND s.fk_stcomm=".$stcomm; $sql .= " AND s.fk_stcomm=".$stcomm;
} }
if (GETPOST("search_nom")) $sql .= natural_search("s.nom", GETPOST("search_nom")); if (GETPOST("search_nom")) {
if (GETPOST("search_compta")) $sql .= natural_search("s.code_compta", GETPOST("search_compta")); $sql .= natural_search("s.nom", GETPOST("search_nom"));
if (GETPOST("search_code_client")) $sql .= natural_search("s.code_client", GETPOST("search_code_client")); }
if (dol_strlen($begin)) if (GETPOST("search_compta")) {
{ $sql .= natural_search("s.code_compta", GETPOST("search_compta"));
}
if (GETPOST("search_code_client")) {
$sql .= natural_search("s.code_client", GETPOST("search_code_client"));
}
if (dol_strlen($begin)) {
$sql .= " AND s.nom like '".$db->escape($begin)."'"; $sql .= " AND s.nom like '".$db->escape($begin)."'";
} }
if ($socid > 0) if ($socid > 0) {
{
$sql .= " AND s.rowid = ".$socid; $sql .= " AND s.rowid = ".$socid;
} }
$sql .= " AND c.fk_statut in (1, 2) AND c.facture = 0"; $sql .= " AND c.fk_statut in (1, 2) AND c.facture = 0";
@ -98,13 +113,11 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -114,8 +127,7 @@ $sql .= $db->plimit($limit + 1, $offset);
//print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
@ -155,8 +167,7 @@ if ($resql)
print "</tr>\n"; print "</tr>\n";
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';

View File

@ -45,8 +45,7 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref'); $ref = GETPOST('ref');
// Security check // Security check
if ($user->socid) if ($user->socid) {
{
$socid = $user->socid; $socid = $user->socid;
} }
$result = restrictedArea($user, 'commande', $id, ''); $result = restrictedArea($user, 'commande', $id, '');
@ -56,16 +55,26 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; } if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; } $sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
}
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) {
$sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
}
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new Commande($db); $object = new Commande($db);
@ -74,8 +83,7 @@ $object = new Commande($db);
* Actions * Actions
*/ */
if ($object->fetch($id)) if ($object->fetch($id)) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$upload_dir = $conf->commande->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $upload_dir = $conf->commande->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref);
} }
@ -91,10 +99,8 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|
$form = new Form($db); $form = new Form($db);
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{ if ($object->fetch($id, $ref)) {
if ($object->fetch($id, $ref))
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$upload_dir = $conf->commande->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->commande->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
@ -105,8 +111,7 @@ if ($id > 0 || !empty($ref))
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0; $totalsize = 0;
foreach ($filearray as $key => $file) foreach ($filearray as $key => $file) {
{
$totalsize += $file['size']; $totalsize += $file['size'];
} }
@ -122,12 +127,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer) if ($user->rights->commande->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

View File

@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (!$user->rights->commande->lire) accessforbidden(); if (!$user->rights->commande->lire) {
accessforbidden();
}
$hookmanager = new HookManager($db); $hookmanager = new HookManager($db);
@ -43,8 +45,7 @@ $langs->loadLangs(array('orders', 'bills'));
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid > 0) if ($user->socid > 0) {
{
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
@ -69,8 +70,7 @@ print load_fiche_titre($langs->trans("OrdersArea"), '', 'order');
print '<div class="fichecenter"><div class="fichethirdleft">'; 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 if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
{
// Search customer orders // Search customer orders
print '<form method="post" action="'.DOL_URL_ROOT.'/commande/list.php">'; print '<form method="post" action="'.DOL_URL_ROOT.'/commande/list.php">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
@ -90,16 +90,21 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
$sql = "SELECT count(c.rowid) as nb, c.fk_statut as status"; $sql = "SELECT count(c.rowid) as nb, c.fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('societe').")"; $sql .= " AND c.entity IN (".getEntity('societe').")";
if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; if ($user->socid) {
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= ' AND c.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 .= " GROUP BY c.fk_statut"; $sql .= " GROUP BY c.fk_statut";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
@ -109,14 +114,14 @@ if ($resql)
$colorseries = array(); $colorseries = array();
$vals = array(); $vals = array();
// -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not)
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
if ($row) if ($row) {
{
//if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
{ {
if (!isset($vals[$row[1]])) $vals[$row[1]] = 0; if (!isset($vals[$row[1]])) {
$vals[$row[1]] = 0;
}
$vals[$row[1]] += $row[0]; $vals[$row[1]] += $row[0];
$totalinprocess += $row[0]; $totalinprocess += $row[0];
} }
@ -132,18 +137,28 @@ if ($resql)
print '<table class="noborder nohover centpercent">'; print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'</th></tr>'."\n"; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'</th></tr>'."\n";
$listofstatus = array(0, 1, 2, 3, -1); $listofstatus = array(0, 1, 2, 3, -1);
foreach ($listofstatus as $status) foreach ($listofstatus as $status) {
{
$dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
if ($status == Commande::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; if ($status == Commande::STATUS_DRAFT) {
if ($status == Commande::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; $colorseries[$status] = '-'.$badgeStatus0;
if ($status == Commande::STATUS_SHIPMENTONPROCESS) $colorseries[$status] = $badgeStatus4; }
if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $colorseries[$status] = $badgeStatus6; if ($status == Commande::STATUS_VALIDATED) {
if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) $colorseries[$status] = $badgeStatus6; $colorseries[$status] = $badgeStatus1;
if ($status == Commande::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; }
if ($status == Commande::STATUS_SHIPMENTONPROCESS) {
$colorseries[$status] = $badgeStatus4;
}
if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
$colorseries[$status] = $badgeStatus6;
}
if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
$colorseries[$status] = $badgeStatus6;
}
if ($status == Commande::STATUS_CANCELED) {
$colorseries[$status] = $badgeStatus9;
}
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax)) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$commandestatic->LibStatut($status, 0, 0, 1).'</td>'; print '<td>'.$commandestatic->LibStatut($status, 0, 0, 1).'</td>';
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).' '; print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).' ';
@ -152,8 +167,7 @@ if ($resql)
print "</tr>\n"; print "</tr>\n";
} }
} }
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print '<tr class="impair"><td align="center" colspan="2">'; print '<tr class="impair"><td align="center" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@ -181,35 +195,37 @@ if ($resql)
/* /*
* Draft orders * Draft orders
*/ */
if (!empty($conf->commande->enabled)) if (!empty($conf->commande->enabled)) {
{
$sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; $sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
$sql .= ", s.client"; $sql .= ", s.client";
$sql .= ", s.code_client"; $sql .= ", s.code_client";
$sql .= ", s.canvas"; $sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")"; $sql .= " AND c.entity IN (".getEntity('commande').")";
$sql .= " AND c.fk_statut = 0"; $sql .= " AND c.fk_statut = 0";
if ($socid) $sql .= " AND c.fk_soc = ".$socid; if ($socid) {
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $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;
}
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("DraftOrders").'</th></tr>'; print '<th colspan="2">'.$langs->trans("DraftOrders").'</th></tr>';
$langs->load("orders"); $langs->load("orders");
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num) {
{
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$commandestatic->id = $obj->rowid; $commandestatic->id = $obj->rowid;
@ -254,29 +270,32 @@ $sql .= ", s.code_client";
$sql .= ", s.canvas"; $sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
$sql .= " ".MAIN_DB_PREFIX."societe as s"; $sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")"; $sql .= " AND c.entity IN (".getEntity('commande').")";
//$sql.= " AND c.fk_statut > 2"; //$sql.= " AND c.fk_statut > 2";
if ($socid) $sql .= " AND c.fk_soc = ".$socid; if ($socid) {
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $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;
}
$sql .= " ORDER BY c.tms DESC"; $sql .= " ORDER BY c.tms DESC";
$sql .= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th colspan="4">'.$langs->trans("LastModifiedOrders", $max).'</th></tr>'; print '<th colspan="4">'.$langs->trans("LastModifiedOrders", $max).'</th></tr>';
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num) if ($num) {
{
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -319,32 +338,38 @@ if ($resql)
} }
} }
print "</table></div><br>"; print "</table></div><br>";
} else dol_print_error($db); } else {
dol_print_error($db);
}
$max = 10; $max = 10;
/* /*
* Orders to process * Orders to process
*/ */
if (!empty($conf->commande->enabled)) if (!empty($conf->commande->enabled)) {
{
$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid"; $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid";
$sql .= ", s.client"; $sql .= ", s.client";
$sql .= ", s.code_client"; $sql .= ", s.code_client";
$sql .= ", s.canvas"; $sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")"; $sql .= " AND c.entity IN (".getEntity('commande').")";
$sql .= " AND c.fk_statut = ".Commande::STATUS_VALIDATED; $sql .= " AND c.fk_statut = ".Commande::STATUS_VALIDATED;
if ($socid) $sql .= " AND c.fk_soc = ".$socid; if ($socid) {
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $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;
}
$sql .= " ORDER BY c.rowid DESC"; $sql .= " ORDER BY c.rowid DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -352,11 +377,9 @@ if (!empty($conf->commande->enabled))
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th colspan="4">'.$langs->trans("OrdersToProcess").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status='.Commande::STATUS_VALIDATED.'"><span class="badge">'.$num.'</span></a></th></tr>'; print '<th colspan="4">'.$langs->trans("OrdersToProcess").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status='.Commande::STATUS_VALIDATED.'"><span class="badge">'.$num.'</span></a></th></tr>';
if ($num) if ($num) {
{
$i = 0; $i = 0;
while ($i < $num && $i < $max) while ($i < $num && $i < $max) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap" width="20%">'; print '<td class="nowrap" width="20%">';
@ -405,31 +428,37 @@ if (!empty($conf->commande->enabled))
} }
print "</table></div><br>"; print "</table></div><br>";
} else dol_print_error($db); } else {
dol_print_error($db);
}
} }
/* /*
* Orders that are in process * Orders that are in process
*/ */
if (!empty($conf->commande->enabled)) if (!empty($conf->commande->enabled)) {
{
$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid"; $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid";
$sql .= ", s.client"; $sql .= ", s.client";
$sql .= ", s.code_client"; $sql .= ", s.code_client";
$sql .= ", s.canvas"; $sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")"; $sql .= " AND c.entity IN (".getEntity('commande').")";
$sql .= " AND c.fk_statut = ".Commande::STATUS_ACCEPTED; $sql .= " AND c.fk_statut = ".Commande::STATUS_ACCEPTED;
if ($socid) $sql .= " AND c.fk_soc = ".$socid; if ($socid) {
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $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;
}
$sql .= " ORDER BY c.rowid DESC"; $sql .= " ORDER BY c.rowid DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -437,11 +466,9 @@ if (!empty($conf->commande->enabled))
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th colspan="4">'.$langs->trans("OnProcessOrders").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status='.Commande::STATUS_ACCEPTED.'"><span class="badge">'.$num.'</span></a></th></tr>'; print '<th colspan="4">'.$langs->trans("OnProcessOrders").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status='.Commande::STATUS_ACCEPTED.'"><span class="badge">'.$num.'</span></a></th></tr>';
if ($num) if ($num) {
{
$i = 0; $i = 0;
while ($i < $num && $i < $max) while ($i < $num && $i < $max) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="20%" class="nowrap">'; print '<td width="20%" class="nowrap">';
@ -489,7 +516,9 @@ if (!empty($conf->commande->enabled))
} }
} }
print "</table></div><br>"; print "</table></div><br>";
} else dol_print_error($db); } else {
dol_print_error($db);
}
} }

View File

@ -31,7 +31,9 @@ if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
} }
if (!$user->rights->commande->lire) accessforbidden(); if (!$user->rights->commande->lire) {
accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('orders', 'sendings', 'bills')); $langs->loadLangs(array('orders', 'sendings', 'bills'));
@ -42,12 +44,13 @@ $id = GETPOST("id", 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'commande', $comid, ''); $result = restrictedArea($user, 'commande', $comid, '');
$object = new Commande($db); $object = new Commande($db);
if (!$object->fetch($id, $ref) > 0) if (!$object->fetch($id, $ref) > 0) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -78,12 +81,10 @@ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_cl
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer) if ($user->rights->commande->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

File diff suppressed because it is too large Load Diff

View File

@ -42,13 +42,14 @@ $action = GETPOST('action', 'aZ09');
// Security check // Security check
$socid = 0; $socid = 0;
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'commande', $id, ''); $result = restrictedArea($user, 'commande', $id, '');
$object = new Commande($db); $object = new Commande($db);
if (!$object->fetch($id, $ref) > 0) if (!$object->fetch($id, $ref) > 0) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -71,8 +72,7 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|
$form = new Form($db); $form = new Form($db);
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$head = commande_prepare_head($object); $head = commande_prepare_head($object);
@ -91,12 +91,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer) if ($user->rights->commande->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

View File

@ -39,8 +39,12 @@ $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; $mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer';
if ($mode == 'customer' && !$user->rights->commande->lire) accessforbidden(); if ($mode == 'customer' && !$user->rights->commande->lire) {
if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) accessforbidden(); accessforbidden();
}
if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) {
accessforbidden();
}
$object_status = GETPOST('object_status', 'intcomma'); $object_status = GETPOST('object_status', 'intcomma');
$typent_id = GETPOST('typent_id', 'int'); $typent_id = GETPOST('typent_id', 'int');
@ -49,8 +53,7 @@ $categ_id = GETPOST('categ_id', 'categ_id');
$userid = GETPOST('userid', 'int'); $userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
{
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
@ -78,8 +81,7 @@ $picto = 'order';
$title = $langs->trans("OrdersStatistics"); $title = $langs->trans("OrdersStatistics");
$dir = $conf->commande->dir_temp; $dir = $conf->commande->dir_temp;
if ($mode == 'supplier') if ($mode == 'supplier') {
{
$picto = 'supplier_order'; $picto = 'supplier_order';
$title = $langs->trans("OrdersStatisticsSuppliers"); $title = $langs->trans("OrdersStatisticsSuppliers");
$dir = $conf->fournisseur->commande->dir_temp; $dir = $conf->fournisseur->commande->dir_temp;
@ -92,13 +94,15 @@ print load_fiche_titre($title, '', $picto);
dol_mkdir($dir); dol_mkdir($dir);
$stats = new CommandeStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0)); $stats = new CommandeStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0));
if ($mode == 'customer') if ($mode == 'customer') {
{ if ($object_status != '' && $object_status >= -1) {
if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
}
} }
if ($mode == 'supplier') if ($mode == 'supplier') {
{ if ($object_status != '' && $object_status >= 0) {
if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; $stats->where .= ' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
}
} }
@ -109,25 +113,30 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...) // $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid) if (!$user->rights->societe->client->voir || $user->socid) {
{
$filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png'; $filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') {
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png';
}
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$user->id.'-'.$year.'.png';
}
} else { } else {
$filenamenb = $dir.'/ordersnbinyear-'.$year.'.png'; $filenamenb = $dir.'/ordersnbinyear-'.$year.'.png';
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png'; if ($mode == 'customer') {
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png';
}
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png';
}
} }
$px1 = new DolGraph(); $px1 = new DolGraph();
$mesg = $px1->isGraphKo(); $mesg = $px1->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px1->SetData($data); $px1->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -150,25 +159,30 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
//var_dump($data); //var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...) // $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid) if (!$user->rights->societe->client->voir || $user->socid) {
{
$filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png'; $filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') {
if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png';
}
if ($mode == 'supplier') {
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$user->id.'-'.$year.'.png';
}
} else { } else {
$filenameamount = $dir.'/ordersamountinyear-'.$year.'.png'; $filenameamount = $dir.'/ordersamountinyear-'.$year.'.png';
if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png'; if ($mode == 'customer') {
if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png';
}
if ($mode == 'supplier') {
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png';
}
} }
$px2 = new DolGraph(); $px2 = new DolGraph();
$mesg = $px2->isGraphKo(); $mesg = $px2->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px2->SetData($data); $px2->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -189,25 +203,30 @@ if (!$mesg)
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
if (!$user->rights->societe->client->voir || $user->socid) if (!$user->rights->societe->client->voir || $user->socid) {
{
$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; if ($mode == 'customer') {
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png';
}
if ($mode == 'supplier') {
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png';
}
} else { } else {
$filename_avg = $dir.'/ordersaverage-'.$year.'.png'; $filename_avg = $dir.'/ordersaverage-'.$year.'.png';
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; if ($mode == 'customer') {
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png';
}
if ($mode == 'supplier') {
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png';
}
} }
$px3 = new DolGraph(); $px3 = new DolGraph();
$mesg = $px3->isGraphKo(); $mesg = $px3->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px3->SetData($data); $px3->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -235,7 +254,9 @@ foreach ($data as $val) {
$arrayyears[$val['year']] = $val['year']; $arrayyears[$val['year']] = $val['year'];
} }
} }
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; if (!count($arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
$h = 0; $h = 0;
$head = array(); $head = array();
@ -244,8 +265,12 @@ $head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear'; $head[$h][2] = 'byyear';
$h++; $h++;
if ($mode == 'customer') $type = 'order_stats'; if ($mode == 'customer') {
if ($mode == 'supplier') $type = 'supplier_order_stats'; $type = 'order_stats';
}
if ($mode == 'supplier') {
$type = 'supplier_order_stats';
}
complete_head_from_modules($conf, $langs, null, $head, $h, $type); complete_head_from_modules($conf, $langs, null, $head, $h, $type);
@ -264,24 +289,28 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>'; print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
// Company // Company
print '<tr><td class="left">'.$langs->trans("ThirdParty").'</td><td class="left">'; print '<tr><td class="left">'.$langs->trans("ThirdParty").'</td><td class="left">';
if ($mode == 'customer') $filter = 's.client IN (1,2,3)'; if ($mode == 'customer') {
if ($mode == 'supplier') $filter = 's.fournisseur = 1'; $filter = 's.client IN (1,2,3)';
}
if ($mode == 'supplier') {
$filter = 's.fournisseur = 1';
}
print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"'); print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"');
print '</td></tr>'; print '</td></tr>';
// ThirdParty Type // ThirdParty Type
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>'; print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
$sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1); print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) {
print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>'; print '</td></tr>';
// Category // Category
if ($mode == 'customer') if ($mode == 'customer') {
{
$cat_type = Categorie::TYPE_CUSTOMER; $cat_type = Categorie::TYPE_CUSTOMER;
$cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer"));
} }
if ($mode == 'supplier') if ($mode == 'supplier') {
{
$cat_type = Categorie::TYPE_SUPPLIER; $cat_type = Categorie::TYPE_SUPPLIER;
$cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier"));
} }
@ -293,8 +322,7 @@ print '<tr><td class="left">'.$langs->trans("CreatedBy").'</td><td class="left">
print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
// Status // Status
print '<tr><td class="left">'.$langs->trans("Status").'</td><td class="left">'; print '<tr><td class="left">'.$langs->trans("Status").'</td><td class="left">';
if ($mode == 'customer') if ($mode == 'customer') {
{
$liststatus = array( $liststatus = array(
Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"), Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"),
Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"),
@ -304,15 +332,18 @@ if ($mode == 'customer')
); );
print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'intcomma'), -4); print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'intcomma'), -4);
} }
if ($mode == 'supplier') if ($mode == 'supplier') {
{
$formorder->selectSupplierOrderStatus((strstr($object_status, ',') ? -1 : $object_status), 0, 'object_status'); $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ? -1 : $object_status), 0, 'object_status');
} }
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">'; print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; if (!in_array($year, $arrayyears)) {
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; $arrayyears[$year] = $year;
}
if (!in_array($nowyear, $arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
arsort($arrayyears); arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0); print $form->selectarray('year', $arrayyears, $year, 0);
print '</td></tr>'; print '</td></tr>';
@ -335,11 +366,9 @@ print '<td class="right">%</td>';
print '</tr>'; print '</tr>';
$oldyear = 0; $oldyear = 0;
foreach ($data as $val) foreach ($data as $val) {
{
$year = $val['year']; $year = $val['year'];
while (!empty($year) && $oldyear > $year + 1) while (!empty($year) && $oldyear > $year + 1) { // If we have empty year
{ // If we have empty year
$oldyear--; $oldyear--;
print '<tr class="oddeven" height="24">'; print '<tr class="oddeven" height="24">';
@ -375,7 +404,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs // Show graphs
print '<table class="border centpercent"><tr class="pair nohover"><td align="center">'; print '<table class="border centpercent"><tr class="pair nohover"><td align="center">';
if ($mesg) { print $mesg; } else { if ($mesg) {
print $mesg;
} else {
print $px1->show(); print $px1->show();
print "<br>\n"; print "<br>\n";
print $px2->show(); print $px2->show();

View File

@ -38,12 +38,13 @@ $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1)
$total = 0; $total = 0;
$ilink = 0; $ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink) foreach ($linkedObjectBlock as $key => $objectlink) {
{
$ilink++; $ilink++;
$trclass = 'oddeven'; $trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
$trclass .= ' liste_sub_total';
}
echo '<tr class="'.$trclass.'" >'; echo '<tr class="'.$trclass.'" >';
echo '<td class="linkedcol-element" >'.$langs->trans("CustomerOrder"); echo '<td class="linkedcol-element" >'.$langs->trans("CustomerOrder");
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {