code syntax expedition directory
This commit is contained in:
parent
f7c119e48c
commit
8db4291f88
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,7 @@ class Shipments extends DolibarrApi
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
public static $FIELDS = array(
|
||||
'socid',
|
||||
'origin_id',
|
||||
'origin_type',
|
||||
@ -110,28 +110,37 @@ class Shipments extends DolibarrApi
|
||||
|
||||
// If the internal user must only see his customers, force searching by him
|
||||
$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";
|
||||
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."expedition 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('expedition').')';
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
|
||||
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
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
|
||||
$sql .= " AND t.fk_soc = sc.fk_soc";
|
||||
}
|
||||
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
|
||||
if ($search_sale > 0)
|
||||
{
|
||||
if ($search_sale > 0) {
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -140,8 +149,7 @@ class Shipments extends DolibarrApi
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
@ -152,13 +160,11 @@ class Shipments extends DolibarrApi
|
||||
dol_syslog("API Rest request");
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
$i = 0;
|
||||
while ($i < $min)
|
||||
{
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$shipment_static = new Expedition($this->db);
|
||||
if ($shipment_static->fetch($obj->rowid)) {
|
||||
@ -217,28 +223,28 @@ class Shipments extends DolibarrApi
|
||||
// * @return int
|
||||
// */
|
||||
/*
|
||||
public function getLines($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
public function getLines($id)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->shipment->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Shipment not found');
|
||||
}
|
||||
$result = $this->shipment->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Shipment not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->shipment->getLinesArray();
|
||||
$result = array();
|
||||
foreach ($this->shipment->lines as $line) {
|
||||
array_push($result,$this->_cleanObjectDatas($line));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
*/
|
||||
if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$this->shipment->getLinesArray();
|
||||
$result = array();
|
||||
foreach ($this->shipment->lines as $line) {
|
||||
array_push($result,$this->_cleanObjectDatas($line));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
*/
|
||||
|
||||
// /**
|
||||
// * Add a line to given shipment
|
||||
@ -251,56 +257,56 @@ class Shipments extends DolibarrApi
|
||||
// * @return int
|
||||
// */
|
||||
/*
|
||||
public function postLine($id, $request_data = null)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
public function postLine($id, $request_data = null)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->shipment->fetch($id);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'Shipment not found');
|
||||
}
|
||||
$result = $this->shipment->fetch($id);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'Shipment not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->shipment->addline(
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
$request_data->qty,
|
||||
$request_data->tva_tx,
|
||||
$request_data->localtax1_tx,
|
||||
$request_data->localtax2_tx,
|
||||
$request_data->fk_product,
|
||||
$request_data->remise_percent,
|
||||
$request_data->info_bits,
|
||||
$request_data->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->product_type,
|
||||
$request_data->rang,
|
||||
$request_data->special_code,
|
||||
$fk_parent_line,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit,
|
||||
$request_data->origin,
|
||||
$request_data->origin_id,
|
||||
$request_data->multicurrency_subprice
|
||||
);
|
||||
if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->shipment->addline(
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
$request_data->qty,
|
||||
$request_data->tva_tx,
|
||||
$request_data->localtax1_tx,
|
||||
$request_data->localtax2_tx,
|
||||
$request_data->fk_product,
|
||||
$request_data->remise_percent,
|
||||
$request_data->info_bits,
|
||||
$request_data->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->product_type,
|
||||
$request_data->rang,
|
||||
$request_data->special_code,
|
||||
$fk_parent_line,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit,
|
||||
$request_data->origin,
|
||||
$request_data->origin_id,
|
||||
$request_data->multicurrency_subprice
|
||||
);
|
||||
|
||||
if ($updateRes > 0) {
|
||||
return $updateRes;
|
||||
if ($updateRes > 0) {
|
||||
return $updateRes;
|
||||
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
|
||||
// /**
|
||||
// * Update a line to given shipment
|
||||
@ -314,53 +320,53 @@ class Shipments extends DolibarrApi
|
||||
// * @return object
|
||||
// */
|
||||
/*
|
||||
public function putLine($id, $lineid, $request_data = null)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->expedition->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
public function putLine($id, $lineid, $request_data = null)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->expedition->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$result = $this->shipment->fetch($id);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'Shipment not found');
|
||||
}
|
||||
$result = $this->shipment->fetch($id);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'Shipment not found');
|
||||
}
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->shipment->updateline(
|
||||
$lineid,
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
$request_data->qty,
|
||||
$request_data->remise_percent,
|
||||
$request_data->tva_tx,
|
||||
$request_data->localtax1_tx,
|
||||
$request_data->localtax2_tx,
|
||||
'HT',
|
||||
$request_data->info_bits,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->product_type,
|
||||
$request_data->fk_parent_line,
|
||||
0,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->special_code,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit,
|
||||
$request_data->multicurrency_subprice
|
||||
);
|
||||
if( ! DolibarrApi::_checkAccessToResource('expedition',$this->shipment->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->shipment->updateline(
|
||||
$lineid,
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
$request_data->qty,
|
||||
$request_data->remise_percent,
|
||||
$request_data->tva_tx,
|
||||
$request_data->localtax1_tx,
|
||||
$request_data->localtax2_tx,
|
||||
'HT',
|
||||
$request_data->info_bits,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->product_type,
|
||||
$request_data->fk_parent_line,
|
||||
0,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->special_code,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit,
|
||||
$request_data->multicurrency_subprice
|
||||
);
|
||||
|
||||
if ($updateRes > 0) {
|
||||
$result = $this->get($id);
|
||||
unset($result->line);
|
||||
return $this->_cleanObjectDatas($result);
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
if ($updateRes > 0) {
|
||||
$result = $this->get($id);
|
||||
unset($result->line);
|
||||
return $this->_cleanObjectDatas($result);
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Delete a line to given shipment
|
||||
@ -425,12 +431,13 @@ class Shipments extends DolibarrApi
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
if ($field == 'id') {
|
||||
continue;
|
||||
}
|
||||
$this->shipment->$field = $value;
|
||||
}
|
||||
|
||||
if ($this->shipment->update(DolibarrApiAccess::$user) > 0)
|
||||
{
|
||||
if ($this->shipment->update(DolibarrApiAccess::$user) > 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, $this->shipment->error);
|
||||
@ -539,27 +546,27 @@ class Shipments extends DolibarrApi
|
||||
// * @throws RestException 405
|
||||
// */
|
||||
/*
|
||||
public function setinvoiced($id)
|
||||
{
|
||||
public function setinvoiced($id)
|
||||
{
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(empty($id)) {
|
||||
throw new RestException(400, 'Shipment ID is mandatory');
|
||||
}
|
||||
$result = $this->shipment->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Shipment not found');
|
||||
}
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(empty($id)) {
|
||||
throw new RestException(400, 'Shipment ID is mandatory');
|
||||
}
|
||||
$result = $this->shipment->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Shipment not found');
|
||||
}
|
||||
|
||||
$result = $this->shipment->classifyBilled(DolibarrApiAccess::$user);
|
||||
if( $result < 0) {
|
||||
throw new RestException(400, $this->shipment->error);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
*/
|
||||
$result = $this->shipment->classifyBilled(DolibarrApiAccess::$user);
|
||||
if( $result < 0) {
|
||||
throw new RestException(400, $this->shipment->error);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// /**
|
||||
@ -576,35 +583,35 @@ class Shipments extends DolibarrApi
|
||||
// * @throws RestException 405
|
||||
// */
|
||||
/*
|
||||
public function createShipmentFromOrder($orderid)
|
||||
{
|
||||
public function createShipmentFromOrder($orderid)
|
||||
{
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(empty($proposalid)) {
|
||||
throw new RestException(400, 'Order ID is mandatory');
|
||||
}
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(! DolibarrApiAccess::$user->rights->expedition->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if(empty($proposalid)) {
|
||||
throw new RestException(400, 'Order ID is mandatory');
|
||||
}
|
||||
|
||||
$order = new Commande($this->db);
|
||||
$result = $order->fetch($proposalid);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Order not found');
|
||||
}
|
||||
$order = new Commande($this->db);
|
||||
$result = $order->fetch($proposalid);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Order not found');
|
||||
}
|
||||
|
||||
$result = $this->shipment->createFromOrder($order, DolibarrApiAccess::$user);
|
||||
if( $result < 0) {
|
||||
throw new RestException(405, $this->shipment->error);
|
||||
}
|
||||
$this->shipment->fetchObjectLinked();
|
||||
return $this->_cleanObjectDatas($this->shipment);
|
||||
}
|
||||
*/
|
||||
$result = $this->shipment->createFromOrder($order, DolibarrApiAccess::$user);
|
||||
if( $result < 0) {
|
||||
throw new RestException(405, $this->shipment->error);
|
||||
}
|
||||
$this->shipment->fetchObjectLinked();
|
||||
return $this->_cleanObjectDatas($this->shipment);
|
||||
}
|
||||
*/
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||
/**
|
||||
@ -627,10 +634,8 @@ class Shipments extends DolibarrApi
|
||||
unset($object->barcode_type_label);
|
||||
unset($object->barcode_type_coder);
|
||||
|
||||
if (!empty($object->lines) && is_array($object->lines))
|
||||
{
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
if (!empty($object->lines) && is_array($object->lines)) {
|
||||
foreach ($object->lines as $line) {
|
||||
unset($line->tva_tx);
|
||||
unset($line->vat_src_code);
|
||||
unset($line->total_ht);
|
||||
@ -656,8 +661,9 @@ class Shipments extends DolibarrApi
|
||||
{
|
||||
$shipment = array();
|
||||
foreach (Shipments::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
if (!isset($data[$field])) {
|
||||
throw new RestException(400, "$field field missing");
|
||||
}
|
||||
$shipment[$field] = $data[$field];
|
||||
}
|
||||
return $shipment;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -75,10 +75,8 @@ class ExpeditionLineBatch extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->sellby = $this->db->jdate($obj->sellby);
|
||||
@ -126,16 +124,16 @@ class ExpeditionLineBatch extends CommonObject
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element);
|
||||
$this->fk_expeditiondet = $id_line_expdet;
|
||||
return $this->id;
|
||||
} else {
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -159,8 +157,7 @@ class ExpeditionLineBatch extends CommonObject
|
||||
$sql .= " WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".$id_expedition.")";
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
if ($db->query($sql))
|
||||
{
|
||||
if ($db->query($sql)) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
@ -185,27 +182,23 @@ class ExpeditionLineBatch extends CommonObject
|
||||
$sql .= " eb.batch,";
|
||||
$sql .= " eb.qty,";
|
||||
$sql .= " eb.fk_origin_stock";
|
||||
if ($fk_product > 0)
|
||||
{
|
||||
if ($fk_product > 0) {
|
||||
$sql .= ", pl.sellby";
|
||||
$sql .= ", pl.eatby";
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as eb";
|
||||
if ($fk_product > 0)
|
||||
{
|
||||
if ($fk_product > 0) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON pl.batch = eb.batch AND pl.fk_product = ".$fk_product;
|
||||
}
|
||||
$sql .= " WHERE fk_expeditiondet=".(int) $id_line_expdet;
|
||||
|
||||
dol_syslog(__METHOD__."", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$ret = array();
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$tmp = new self($db);
|
||||
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
@ -73,12 +73,15 @@ class ExpeditionStats extends Stats
|
||||
|
||||
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
||||
$this->where .= " AND c.entity = ".$conf->entity;
|
||||
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
if ($this->socid)
|
||||
{
|
||||
if (!$user->rights->societe->client->voir && !$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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +97,9 @@ class ExpeditionStats extends Stats
|
||||
|
||||
$sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
|
||||
$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 .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
|
||||
$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
@ -116,7 +121,9 @@ class ExpeditionStats extends Stats
|
||||
|
||||
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
|
||||
$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 .= " WHERE ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
@ -135,7 +142,9 @@ class ExpeditionStats extends Stats
|
||||
|
||||
$sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg";
|
||||
$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 .= " WHERE ".$this->where;
|
||||
$sql .= " GROUP BY year";
|
||||
$sql .= $this->db->order('year', 'DESC');
|
||||
|
||||
@ -42,30 +42,28 @@ $ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'expedition', $id, '');
|
||||
|
||||
$object = new Expedition($db);
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object->fetch($id, $ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if (!empty($object->origin))
|
||||
{
|
||||
if (!empty($object->origin)) {
|
||||
$typeobject = $object->origin;
|
||||
$origin = $object->origin;
|
||||
$object->fetch_origin();
|
||||
}
|
||||
|
||||
// Linked documents
|
||||
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
|
||||
{
|
||||
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
|
||||
$objectsrc = new Commande($db);
|
||||
$objectsrc->fetch($object->$typeobject->id);
|
||||
}
|
||||
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
|
||||
{
|
||||
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
|
||||
$objectsrc = new Propal($db);
|
||||
$objectsrc->fetch($object->$typeobject->id);
|
||||
}
|
||||
@ -76,22 +74,18 @@ if ($id > 0 || !empty($ref))
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcontact' && $user->rights->expedition->creer)
|
||||
{
|
||||
if ($result > 0 && $id > 0)
|
||||
{
|
||||
if ($action == 'addcontact' && $user->rights->expedition->creer) {
|
||||
if ($result > 0 && $id > 0) {
|
||||
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
|
||||
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
|
||||
$result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
|
||||
}
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
if ($objectsrc->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
$mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
|
||||
} else {
|
||||
@ -100,21 +94,14 @@ if ($action == 'addcontact' && $user->rights->expedition->creer)
|
||||
}
|
||||
setEventMessages($mesg, $mesgs, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// bascule du statut d'un contact
|
||||
elseif ($action == 'swapstatut' && $user->rights->expedition->creer)
|
||||
{
|
||||
} elseif ($action == 'swapstatut' && $user->rights->expedition->creer) {
|
||||
// bascule du statut d'un contact
|
||||
$result = $objectsrc->swapContactStatus(GETPOST('ligne'));
|
||||
}
|
||||
|
||||
// Efface un contact
|
||||
elseif ($action == 'deletecontact' && $user->rights->expedition->creer)
|
||||
{
|
||||
} elseif ($action == 'deletecontact' && $user->rights->expedition->creer) {
|
||||
// Efface un contact
|
||||
$result = $objectsrc->delete_contact(GETPOST("lineid"));
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
} else {
|
||||
@ -149,8 +136,7 @@ $userstatic = new User($db);
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$langs->trans("OrderCard");
|
||||
|
||||
$head = shipping_prepare_head($object);
|
||||
@ -213,8 +199,7 @@ if ($id > 0 || !empty($ref))
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
// Linked documents
|
||||
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
|
||||
{
|
||||
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
|
||||
print '<tr><td class="titlefield">';
|
||||
$objectsrc = new Commande($db);
|
||||
$objectsrc->fetch($object->$typeobject->id);
|
||||
@ -224,8 +209,7 @@ if ($id > 0 || !empty($ref))
|
||||
print "</td>\n";
|
||||
print '</tr>';
|
||||
}
|
||||
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
|
||||
{
|
||||
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
|
||||
print '<tr><td class="titlefield">';
|
||||
$objectsrc = new Propal($db);
|
||||
$objectsrc->fetch($object->$typeobject->id);
|
||||
@ -260,10 +244,11 @@ if ($id > 0 || !empty($ref))
|
||||
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
|
||||
$preselectedtypeofcontact = dol_getIdFromCode($db, 'SHIPPING', 'c_type_contact', 'code', 'rowid');
|
||||
foreach ($dirtpls as $reldir)
|
||||
{
|
||||
foreach ($dirtpls as $reldir) {
|
||||
$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
|
||||
if ($res) break;
|
||||
if ($res) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -46,8 +46,7 @@ $id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref');
|
||||
|
||||
// Security check
|
||||
if ($user->socid)
|
||||
{
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'expedition', $id, '');
|
||||
@ -57,12 +56,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$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;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "name";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "name";
|
||||
}
|
||||
|
||||
$object = new Expedition($db);
|
||||
|
||||
@ -70,8 +75,7 @@ $object = new Expedition($db);
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
if ($object->fetch($id)) {
|
||||
$object->fetch_thirdparty();
|
||||
$upload_dir = $conf->expedition->dir_output."/sending/".dol_sanitizeFileName($object->ref);
|
||||
}
|
||||
|
||||
@ -54,8 +54,7 @@ print load_fiche_titre($langs->trans("SendingsArea"), '', 'dolly');
|
||||
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
|
||||
print '<form method="post" action="list.php">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
@ -79,19 +78,19 @@ $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
|
||||
if (!$user->rights->societe->client->voir && !$socid)
|
||||
{
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
|
||||
$sql .= $clause." sc.fk_user = ".$user->id;
|
||||
$clause = " AND ";
|
||||
}
|
||||
$sql .= $clause." e.fk_statut = ".Expedition::STATUS_DRAFT;
|
||||
$sql .= " AND e.entity IN (".getEntity('expedition').")";
|
||||
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
|
||||
if ($socid) {
|
||||
$sql .= " AND c.fk_soc = ".$socid;
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
@ -105,11 +104,9 @@ if ($resql)
|
||||
print '</th>';
|
||||
print '</tr>';
|
||||
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$shipment->id = $obj->rowid;
|
||||
@ -123,7 +120,9 @@ if ($resql)
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($obj->commande_id) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$obj->commande_id.'">'.$obj->commande_ref.'</a>';
|
||||
if ($obj->commande_id) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$obj->commande_id.'">'.$obj->commande_ref.'</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
@ -151,17 +150,22 @@ $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
|
||||
}
|
||||
$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= " AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
$sql .= " AND e.fk_statut = ".Expedition::STATUS_VALIDATED;
|
||||
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
|
||||
if ($socid) {
|
||||
$sql .= " AND c.fk_soc = ".$socid;
|
||||
}
|
||||
$sql .= " ORDER BY e.date_delivery DESC";
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
@ -175,11 +179,9 @@ if ($resql)
|
||||
print '</th>';
|
||||
print '</tr>';
|
||||
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$shipment->id = $obj->rowid;
|
||||
@ -191,8 +193,7 @@ if ($resql)
|
||||
print '</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.'</a></td>';
|
||||
print '<td>';
|
||||
if ($obj->commande_id > 0)
|
||||
{
|
||||
if ($obj->commande_id > 0) {
|
||||
$orderstatic->id = $obj->commande_id;
|
||||
$orderstatic->ref = $obj->commande_ref;
|
||||
print $orderstatic->getNomUrl(1);
|
||||
@ -209,7 +210,9 @@ if ($resql)
|
||||
}
|
||||
print "</table></div><br>";
|
||||
$db->free($resql);
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Open orders
|
||||
@ -217,17 +220,22 @@ if ($resql)
|
||||
$sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, c.fk_statut as status, c.facture as billed, s.nom as name, s.rowid as socid";
|
||||
$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";
|
||||
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('order').")";
|
||||
$sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_ACCEPTED.")";
|
||||
if ($socid > 0) $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;
|
||||
if ($socid > 0) {
|
||||
$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 ASC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$langs->load("orders");
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
@ -243,11 +251,9 @@ if ($resql)
|
||||
print '</th>';
|
||||
print '</tr>';
|
||||
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
$i = 0;
|
||||
while ($i < $num && $i < 10)
|
||||
{
|
||||
while ($i < $num && $i < 10) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$orderstatic->id = $obj->rowid;
|
||||
@ -284,7 +290,9 @@ if ($resql)
|
||||
}
|
||||
|
||||
print "</table></div><br>";
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
print '</div></div></div>';
|
||||
|
||||
@ -49,7 +49,9 @@ $toselect = GETPOST('toselect', 'array');
|
||||
|
||||
// Security check
|
||||
$expeditionid = GETPOST('id', 'int');
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'expedition', $expeditionid, '');
|
||||
|
||||
$search_ref_exp = GETPOST("search_ref_exp", 'alpha');
|
||||
@ -79,9 +81,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (!$sortfield) $sortfield = "e.ref";
|
||||
if (!$sortorder) $sortorder = "DESC";
|
||||
if (empty($page) || $page == -1 || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (!$sortfield) {
|
||||
$sortfield = "e.ref";
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
if (empty($page) || $page == -1 || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
@ -109,7 +117,9 @@ $fieldstosearchall = array(
|
||||
'e.note_public'=>'NotePublic',
|
||||
'e.tracking_number'=>"TrackingNumber",
|
||||
);
|
||||
if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate";
|
||||
if (empty($user->socid)) {
|
||||
$fieldstosearchall["e.note_private"] = "NotePrivate";
|
||||
}
|
||||
|
||||
$checkedtypetiers = 0;
|
||||
$arrayfields = array(
|
||||
@ -144,18 +154,23 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
*/
|
||||
$error = 0;
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array('socid'=>$socid);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$search_categ = '';
|
||||
$search_user = '';
|
||||
$search_sale = '';
|
||||
@ -182,8 +197,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
||||
$search_categ_cus = 0;
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
$objectclass = 'Expedition';
|
||||
$objectlabel = 'Sendings';
|
||||
$permissiontoread = $user->rights->expedition->lire;
|
||||
@ -211,7 +225,9 @@ $helpurl = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Ex
|
||||
llxHeader('', $langs->trans('ListOfSendings'), $helpurl);
|
||||
|
||||
$sql = 'SELECT';
|
||||
if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
|
||||
if ($sall || $search_product_category > 0 || $search_user > 0) {
|
||||
$sql = 'SELECT DISTINCT';
|
||||
}
|
||||
$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, e.fk_statut, e.billed, e.tracking_number,";
|
||||
$sql .= " l.date_delivery as date_reception,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ";
|
||||
@ -219,24 +235,34 @@ $sql .= " typent.code as typent_code,";
|
||||
$sql .= " state.code_departement as state_code, state.nom as state_name,";
|
||||
$sql .= " e.date_creation as date_creation, e.tms as date_update,";
|
||||
$sql .= " u.login";
|
||||
if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
|
||||
if ($search_categ_cus) {
|
||||
$sql .= ", cc.fk_categorie, cc.fk_soc";
|
||||
}
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
||||
}
|
||||
}
|
||||
// Add fields from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
|
||||
}
|
||||
if ($sall || $search_product_category > 0) {
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet as ed ON e.rowid=ed.fk_expedition';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON pd.rowid=ed.fk_origin_line';
|
||||
}
|
||||
if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
|
||||
if ($search_product_category > 0) {
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
|
||||
if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
|
||||
if (!empty($search_categ_cus)) {
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
|
||||
@ -247,50 +273,91 @@ if ($search_user > 0) { // Get link to order to get the order id in eesource.fk
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as eesource ON eesource.fk_target = e.rowid AND eesource.targettype = 'shipping' AND eesource.sourcetype = 'commande'";
|
||||
}
|
||||
// We'll need this table joined to the select in order to filter by sale
|
||||
if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
if ($search_user > 0) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||
}
|
||||
$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
|
||||
if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category;
|
||||
if ($socid > 0) $sql .= ' AND s.rowid = '.$socid;
|
||||
if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all
|
||||
{
|
||||
if ($search_product_category > 0) {
|
||||
$sql .= " AND cp.fk_categorie = ".$search_product_category;
|
||||
}
|
||||
if ($socid > 0) {
|
||||
$sql .= ' AND s.rowid = '.$socid;
|
||||
}
|
||||
if (!$user->rights->societe->client->voir && !$socid) { // Internal user with no permission to see all
|
||||
$sql .= " AND e.fk_soc = sc.fk_soc";
|
||||
$sql .= " AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($socid)
|
||||
{
|
||||
if ($socid) {
|
||||
$sql .= " AND e.fk_soc = ".$socid;
|
||||
}
|
||||
if ($search_status <> '' && $search_status >= 0) {
|
||||
$sql .= " AND e.fk_statut = ".$search_status;
|
||||
}
|
||||
if ($search_ref_customer != '') $sql .= natural_search('e.ref_customer', $search_ref_customer);
|
||||
if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed;
|
||||
if ($search_town) $sql .= natural_search('s.town', $search_town);
|
||||
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
|
||||
if ($search_state) $sql .= natural_search("state.nom", $search_state);
|
||||
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
|
||||
if ($search_tracking) $sql .= natural_search("e.tracking_number", $search_tracking);
|
||||
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
|
||||
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
|
||||
if ($search_user > 0)
|
||||
{
|
||||
if ($search_ref_customer != '') {
|
||||
$sql .= natural_search('e.ref_customer', $search_ref_customer);
|
||||
}
|
||||
if ($search_billed != '' && $search_billed >= 0) {
|
||||
$sql .= ' AND e.billed = '.$search_billed;
|
||||
}
|
||||
if ($search_town) {
|
||||
$sql .= natural_search('s.town', $search_town);
|
||||
}
|
||||
if ($search_zip) {
|
||||
$sql .= natural_search("s.zip", $search_zip);
|
||||
}
|
||||
if ($search_state) {
|
||||
$sql .= natural_search("state.nom", $search_state);
|
||||
}
|
||||
if ($search_country) {
|
||||
$sql .= " AND s.fk_pays IN (".$search_country.')';
|
||||
}
|
||||
if ($search_tracking) {
|
||||
$sql .= natural_search("e.tracking_number", $search_tracking);
|
||||
}
|
||||
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
|
||||
$sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
|
||||
}
|
||||
if ($search_sale > 0) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
if ($search_user > 0) {
|
||||
// The contact on a shipment is also the contact of the order.
|
||||
$sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = eesource.fk_source AND ec.fk_socpeople = ".$db->escape($search_user);
|
||||
}
|
||||
if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
|
||||
if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
|
||||
if ($search_company) $sql .= natural_search('s.nom', $search_company);
|
||||
if ($search_datedelivery_start) $sql .= " AND e.date_delivery >= '".$db->idate($search_datedelivery_start)."'";
|
||||
if ($search_datedelivery_end) $sql .= " AND e.date_delivery <= '".$db->idate($search_datedelivery_end)."'";
|
||||
if ($search_datereceipt_start) $sql .= " AND l.date_delivery >= '".$db->idate($search_datereceipt_start)."'";
|
||||
if ($search_datereceipt_end) $sql .= " AND l.date_delivery <= '".$db->idate($search_datereceipt_end)."'";
|
||||
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
|
||||
if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
|
||||
if ($search_ref_exp) {
|
||||
$sql .= natural_search('e.ref', $search_ref_exp);
|
||||
}
|
||||
if ($search_ref_liv) {
|
||||
$sql .= natural_search('l.ref', $search_ref_liv);
|
||||
}
|
||||
if ($search_company) {
|
||||
$sql .= natural_search('s.nom', $search_company);
|
||||
}
|
||||
if ($search_datedelivery_start) {
|
||||
$sql .= " AND e.date_delivery >= '".$db->idate($search_datedelivery_start)."'";
|
||||
}
|
||||
if ($search_datedelivery_end) {
|
||||
$sql .= " AND e.date_delivery <= '".$db->idate($search_datedelivery_end)."'";
|
||||
}
|
||||
if ($search_datereceipt_start) {
|
||||
$sql .= " AND l.date_delivery >= '".$db->idate($search_datereceipt_start)."'";
|
||||
}
|
||||
if ($search_datereceipt_end) {
|
||||
$sql .= " AND l.date_delivery <= '".$db->idate($search_datereceipt_end)."'";
|
||||
}
|
||||
if ($sall) {
|
||||
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
}
|
||||
if ($search_categ_cus > 0) {
|
||||
$sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
|
||||
}
|
||||
if ($search_categ_cus == -2) {
|
||||
$sql .= " AND cc.fk_categorie IS NULL";
|
||||
}
|
||||
|
||||
// Add where from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||
@ -303,12 +370,10 @@ $sql .= $hookmanager->resPrint;
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$result = $db->query($sql);
|
||||
$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;
|
||||
$offset = 0;
|
||||
}
|
||||
@ -318,8 +383,7 @@ $sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
@ -327,29 +391,71 @@ if ($resql)
|
||||
$expedition = new Expedition($db);
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($sall) $param .= "&sall=".urlencode($sall);
|
||||
if ($search_ref_exp) $param .= "&search_ref_exp=".urlencode($search_ref_exp);
|
||||
if ($search_ref_liv) $param .= "&search_ref_liv=".urlencode($search_ref_liv);
|
||||
if ($search_ref_customer) $param .= "&search_ref_customer=".urlencode($search_ref_customer);
|
||||
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
|
||||
if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
|
||||
if ($search_company) $param .= "&search_company=".urlencode($search_company);
|
||||
if ($search_tracking) $param .= "&search_tracking=".urlencode($search_tracking);
|
||||
if ($search_town) $param .= '&search_town='.urlencode($search_town);
|
||||
if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
|
||||
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($sall) {
|
||||
$param .= "&sall=".urlencode($sall);
|
||||
}
|
||||
if ($search_ref_exp) {
|
||||
$param .= "&search_ref_exp=".urlencode($search_ref_exp);
|
||||
}
|
||||
if ($search_ref_liv) {
|
||||
$param .= "&search_ref_liv=".urlencode($search_ref_liv);
|
||||
}
|
||||
if ($search_ref_customer) {
|
||||
$param .= "&search_ref_customer=".urlencode($search_ref_customer);
|
||||
}
|
||||
if ($search_user > 0) {
|
||||
$param .= '&search_user='.urlencode($search_user);
|
||||
}
|
||||
if ($search_sale > 0) {
|
||||
$param .= '&search_sale='.urlencode($search_sale);
|
||||
}
|
||||
if ($search_company) {
|
||||
$param .= "&search_company=".urlencode($search_company);
|
||||
}
|
||||
if ($search_tracking) {
|
||||
$param .= "&search_tracking=".urlencode($search_tracking);
|
||||
}
|
||||
if ($search_town) {
|
||||
$param .= '&search_town='.urlencode($search_town);
|
||||
}
|
||||
if ($search_zip) {
|
||||
$param .= '&search_zip='.urlencode($search_zip);
|
||||
}
|
||||
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
|
||||
$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
|
||||
}
|
||||
|
||||
if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start);
|
||||
if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end);
|
||||
if ($search_datereceipt_start) $param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start);
|
||||
if ($search_datereceipt_end) $param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end);
|
||||
if ($search_datedelivery_start) {
|
||||
$param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start);
|
||||
}
|
||||
if ($search_datedelivery_end) {
|
||||
$param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end);
|
||||
}
|
||||
if ($search_datereceipt_start) {
|
||||
$param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start);
|
||||
}
|
||||
if ($search_datereceipt_end) {
|
||||
$param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end);
|
||||
}
|
||||
|
||||
if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category);
|
||||
if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
|
||||
if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($search_product_category != '') {
|
||||
$param .= '&search_product_category='.urlencode($search_product_category);
|
||||
}
|
||||
if ($search_categ_cus > 0) {
|
||||
$param .= '&search_categ_cus='.urlencode($search_categ_cus);
|
||||
}
|
||||
if ($search_status != '') {
|
||||
$param .= '&search_status='.urlencode($search_status);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
@ -358,7 +464,9 @@ if ($resql)
|
||||
//'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged
|
||||
'presend' => $langs->trans("SendByMail"),
|
||||
);
|
||||
if (in_array($massaction, array('presend'))) $arrayofmassactions = array();
|
||||
if (in_array($massaction, array('presend'))) {
|
||||
$arrayofmassactions = array();
|
||||
}
|
||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
// Currently: a sending can't create from sending list
|
||||
@ -369,7 +477,9 @@ if ($resql)
|
||||
|
||||
$i = 0;
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
@ -384,34 +494,32 @@ if ($resql)
|
||||
$trackid = 'shi'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
||||
if ($sall) {
|
||||
foreach ($fieldstosearchall as $key => $val) {
|
||||
$fieldstosearchall[$key] = $langs->trans($val);
|
||||
}
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
|
||||
$moreforfilter = '';
|
||||
|
||||
// If the user can view prospects other than his'
|
||||
if ($user->rights->societe->client->voir || $socid)
|
||||
{
|
||||
$langs->load("commercial");
|
||||
// If the user can view prospects other than his'
|
||||
if ($user->rights->societe->client->voir || $socid) {
|
||||
$langs->load("commercial");
|
||||
$moreforfilter .= '<div class="divsearchfield">';
|
||||
$moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': ';
|
||||
$moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': ';
|
||||
$moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200');
|
||||
$moreforfilter .= '</div>';
|
||||
}
|
||||
$moreforfilter .= '</div>';
|
||||
}
|
||||
// If the user can view other users
|
||||
if ($user->rights->user->user->lire)
|
||||
{
|
||||
if ($user->rights->user->user->lire) {
|
||||
$moreforfilter .= '<div class="divsearchfield">';
|
||||
$moreforfilter .= $langs->trans('LinkedToSpecificUsers').': ';
|
||||
$moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
|
||||
$moreforfilter .= '</div>';
|
||||
$moreforfilter .= '</div>';
|
||||
}
|
||||
// If the user can view prospects other than his'
|
||||
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire))
|
||||
{
|
||||
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$moreforfilter .= '<div class="divsearchfield">';
|
||||
$moreforfilter .= $langs->trans('IncludingProductWithTag').': ';
|
||||
@ -419,21 +527,22 @@ if ($resql)
|
||||
$moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
|
||||
$moreforfilter .= '</div>';
|
||||
}
|
||||
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
|
||||
{
|
||||
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$moreforfilter .= '<div class="divsearchfield">';
|
||||
$moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': ';
|
||||
$moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': ';
|
||||
$moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1);
|
||||
$moreforfilter .= '</div>';
|
||||
$moreforfilter .= '</div>';
|
||||
}
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
if (empty($reshook)) {
|
||||
$moreforfilter .= $hookmanager->resPrint;
|
||||
} else {
|
||||
$moreforfilter = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
if (!empty($moreforfilter))
|
||||
{
|
||||
if (!empty($moreforfilter)) {
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
@ -441,7 +550,9 @@ if ($resql)
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);
|
||||
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields
|
||||
if ($massactionbutton) {
|
||||
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
@ -449,61 +560,57 @@ if ($resql)
|
||||
// Fields title search
|
||||
print '<tr class="liste_titre_filter">';
|
||||
// Ref
|
||||
if (!empty($arrayfields['e.ref']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.ref']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Ref customer
|
||||
if (!empty($arrayfields['e.ref_customer']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.ref_customer']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Thirdparty
|
||||
if (!empty($arrayfields['s.nom']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['s.nom']['checked'])) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Town
|
||||
if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
|
||||
if (!empty($arrayfields['s.town']['checked'])) {
|
||||
print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
|
||||
}
|
||||
// Zip
|
||||
if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
|
||||
if (!empty($arrayfields['s.zip']['checked'])) {
|
||||
print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
|
||||
}
|
||||
// State
|
||||
if (!empty($arrayfields['state.nom']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['state.nom']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Country
|
||||
if (!empty($arrayfields['country.code_iso']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['country.code_iso']['checked'])) {
|
||||
print '<td class="liste_titre center">';
|
||||
print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
|
||||
print '</td>';
|
||||
}
|
||||
// Company type
|
||||
if (!empty($arrayfields['typent.code']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['typent.code']['checked'])) {
|
||||
print '<td class="liste_titre maxwidthonsmartphone center">';
|
||||
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
|
||||
print '</td>';
|
||||
}
|
||||
// Weight
|
||||
if (!empty($arrayfields['e.weight']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.weight']['checked'])) {
|
||||
print '<td class="liste_titre maxwidthonsmartphone center">';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
// Date delivery planned
|
||||
if (!empty($arrayfields['e.date_delivery']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.date_delivery']['checked'])) {
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From').' ';
|
||||
@ -516,21 +623,18 @@ if ($resql)
|
||||
print '</td>';
|
||||
}
|
||||
// Tracking number
|
||||
if (!empty($arrayfields['e.tracking_number']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.tracking_number']['checked'])) {
|
||||
print '<td class="liste_titre center">';
|
||||
print '<input class="flat" size="6" type="text" name="search_tracking" value="'.dol_escape_htmltag($search_tracking).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['l.ref']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['l.ref']['checked'])) {
|
||||
// Delivery ref
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['l.date_delivery']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['l.date_delivery']['checked'])) {
|
||||
// Date received
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
@ -551,27 +655,23 @@ if ($resql)
|
||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Date creation
|
||||
if (!empty($arrayfields['e.datec']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.datec']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Date modification
|
||||
if (!empty($arrayfields['e.tms']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.tms']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Status
|
||||
if (!empty($arrayfields['e.fk_statut']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.fk_statut']['checked'])) {
|
||||
print '<td class="liste_titre maxwidthonsmartphone right">';
|
||||
print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1);
|
||||
print '</td>';
|
||||
}
|
||||
// Status billed
|
||||
if (!empty($arrayfields['e.billed']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.billed']['checked'])) {
|
||||
print '<td class="liste_titre maxwidthonsmartphone center">';
|
||||
print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
|
||||
print '</td>';
|
||||
@ -584,37 +684,70 @@ if ($resql)
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['e.ref_customer']['checked'])) print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['e.weight']['checked'])) print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['e.tracking_number']['checked'])) print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['e.ref']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['e.ref_customer']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['s.nom']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
}
|
||||
if (!empty($arrayfields['s.town']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['s.zip']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['state.nom']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['country.code_iso']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['typent.code']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['e.weight']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['e.date_delivery']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['e.tracking_number']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['l.ref']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['l.date_delivery']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['e.datec']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
}
|
||||
if (!empty($arrayfields['e.tms']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
}
|
||||
if (!empty($arrayfields['e.fk_statut']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
if (!empty($arrayfields['e.billed']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
$typenArray = $formcompany->typent_array(1);
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$shipment->id = $obj->rowid;
|
||||
@ -630,76 +763,84 @@ if ($resql)
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
if (!empty($arrayfields['e.ref']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.ref']['checked'])) {
|
||||
print "<td>";
|
||||
print $shipment->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Ref customer
|
||||
if (!empty($arrayfields['e.ref_customer']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.ref_customer']['checked'])) {
|
||||
print "<td>";
|
||||
print $obj->ref_customer;
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Third party
|
||||
if (!empty($arrayfields['s.nom']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['s.nom']['checked'])) {
|
||||
print '<td>';
|
||||
print $companystatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Town
|
||||
if (!empty($arrayfields['s.town']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['s.town']['checked'])) {
|
||||
print '<td class="nocellnopadd">';
|
||||
print $obj->town;
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Zip
|
||||
if (!empty($arrayfields['s.zip']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['s.zip']['checked'])) {
|
||||
print '<td class="nocellnopadd">';
|
||||
print $obj->zip;
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// State
|
||||
if (!empty($arrayfields['state.nom']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['state.nom']['checked'])) {
|
||||
print "<td>".$obj->state_name."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Country
|
||||
if (!empty($arrayfields['country.code_iso']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['country.code_iso']['checked'])) {
|
||||
print '<td class="center">';
|
||||
$tmparray = getCountry($obj->fk_pays, 'all');
|
||||
print $tmparray['label'];
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Type ent
|
||||
if (!empty($arrayfields['typent.code']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['typent.code']['checked'])) {
|
||||
print '<td class="center">';
|
||||
if (isset($typenArray[$obj->typent_code])) print $typenArray[$obj->typent_code];
|
||||
if (isset($typenArray[$obj->typent_code])) {
|
||||
print $typenArray[$obj->typent_code];
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Weight
|
||||
if (!empty($arrayfields['e.weight']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.weight']['checked'])) {
|
||||
print '<td class="center">';
|
||||
if (empty($object->trueWeight))
|
||||
{
|
||||
if (empty($object->trueWeight)) {
|
||||
$tmparray = $object->getTotalWeightVolume();
|
||||
print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no');
|
||||
print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1);
|
||||
@ -708,42 +849,43 @@ if ($resql)
|
||||
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : '';
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Date delivery planed
|
||||
if (!empty($arrayfields['e.date_delivery']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.date_delivery']['checked'])) {
|
||||
print '<td class="center">';
|
||||
print dol_print_date($db->jdate($obj->delivery_date), "dayhour");
|
||||
/*$now = time();
|
||||
if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 )
|
||||
{
|
||||
}*/
|
||||
if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 )
|
||||
{
|
||||
}*/
|
||||
print "</td>\n";
|
||||
}
|
||||
// Tracking number
|
||||
if (!empty($arrayfields['e.tracking_number']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.tracking_number']['checked'])) {
|
||||
print '<td class="center">'.$obj->tracking_number."</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) {
|
||||
$shipment->fetchObjectLinked($shipment->id, $shipment->element);
|
||||
$receiving = '';
|
||||
if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving = reset($shipment->linkedObjects['delivery']);
|
||||
if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) {
|
||||
$receiving = reset($shipment->linkedObjects['delivery']);
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['l.ref']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['l.ref']['checked'])) {
|
||||
// Ref
|
||||
print '<td>';
|
||||
print !empty($receiving) ? $receiving->getNomUrl($db) : '';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['l.date_delivery']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['l.date_delivery']['checked'])) {
|
||||
// Date received
|
||||
print '<td class="center">';
|
||||
print dol_print_date($db->jdate($obj->date_reception), "day");
|
||||
@ -758,44 +900,51 @@ if ($resql)
|
||||
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Date creation
|
||||
if (!empty($arrayfields['e.datec']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.datec']['checked'])) {
|
||||
print '<td class="center nowrap">';
|
||||
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Date modification
|
||||
if (!empty($arrayfields['e.tms']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.tms']['checked'])) {
|
||||
print '<td class="center nowrap">';
|
||||
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Status
|
||||
if (!empty($arrayfields['e.fk_statut']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.fk_statut']['checked'])) {
|
||||
print '<td class="right nowrap">'.$shipment->LibStatut($obj->fk_statut, 5).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Billed
|
||||
if (!empty($arrayfields['e.billed']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['e.billed']['checked'])) {
|
||||
print '<td class="center">'.yn($obj->billed).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Action column
|
||||
print '<td class="nowrap" align="center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
$selected = 0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
|
||||
if (in_array($obj->rowid, $arrayofselected)) {
|
||||
$selected = 1;
|
||||
}
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
@ -812,7 +961,9 @@ if ($resql)
|
||||
print '</form>';
|
||||
|
||||
$hidegeneratedfilelistifempty = 1;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
|
||||
$hidegeneratedfilelistifempty = 0;
|
||||
}
|
||||
|
||||
// Show list of available documents
|
||||
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||
|
||||
@ -41,30 +41,28 @@ $action = GETPOST('action', 'aZ09');
|
||||
|
||||
// Security check
|
||||
$socid = '';
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, $origin, $origin_id);
|
||||
|
||||
$object = new Expedition($db);
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object->fetch($id, $ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if (!empty($object->origin))
|
||||
{
|
||||
if (!empty($object->origin)) {
|
||||
$typeobject = $object->origin;
|
||||
$origin = $object->origin;
|
||||
$object->fetch_origin();
|
||||
}
|
||||
|
||||
// Linked documents
|
||||
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
|
||||
{
|
||||
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
|
||||
$objectsrc = new Commande($db);
|
||||
$objectsrc->fetch($object->$typeobject->id);
|
||||
}
|
||||
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
|
||||
{
|
||||
if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
|
||||
$objectsrc = new Propal($db);
|
||||
$objectsrc->fetch($object->$typeobject->id);
|
||||
}
|
||||
@ -88,8 +86,7 @@ llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$head = shipping_prepare_head($object);
|
||||
print dol_get_fiche_head($head, 'note', $langs->trans("Shipment"), -1, 'sending');
|
||||
|
||||
|
||||
@ -37,9 +37,15 @@ if (!empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
if (!empty($conf->stock->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
}
|
||||
if (!empty($conf->propal->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
}
|
||||
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('orders', "companies", "bills", 'propal', 'deliveries', 'stocks', "productbatch", 'incoterm', 'other'));
|
||||
@ -53,7 +59,9 @@ $hookmanager->initHooks(array('ordershipmentcard'));
|
||||
|
||||
// Security check
|
||||
$socid = 0;
|
||||
if (!empty($user->socid)) $socid = $user->socid;
|
||||
if (!empty($user->socid)) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'commande', $id);
|
||||
|
||||
$object = new Commande($db);
|
||||
@ -74,93 +82,86 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
|
||||
|
||||
$parameters = array('socid' => $socid);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Categorisation dans projet
|
||||
if ($action == 'classin')
|
||||
{
|
||||
if ($action == 'classin') {
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$object->setProject(GETPOST('projectid', 'int'));
|
||||
}
|
||||
|
||||
if ($action == 'confirm_cloture' && GETPOST('confirm', 'alpha') == 'yes')
|
||||
{
|
||||
if ($action == 'confirm_cloture' && GETPOST('confirm', 'alpha') == 'yes') {
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$result = $object->cloture($user);
|
||||
}
|
||||
|
||||
// Positionne ref commande client
|
||||
elseif ($action == 'setref_client' && $user->rights->commande->creer) {
|
||||
} elseif ($action == 'setref_client' && $user->rights->commande->creer) {
|
||||
// Positionne ref commande client
|
||||
$result = $object->set_ref_client($user, GETPOST('ref_client'));
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setdatedelivery' && $user->rights->commande->creer)
|
||||
{
|
||||
if ($action == 'setdatedelivery' && $user->rights->commande->creer) {
|
||||
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
|
||||
$datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
|
||||
|
||||
$object->fetch($id);
|
||||
$result = $object->setDeliveryDate($user, $datedelivery);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
/*
|
||||
if ($action == 'setdeliveryaddress' && $user->rights->commande->creer)
|
||||
{
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$object->setDeliveryAddress(GETPOST('delivery_address_id','int'));
|
||||
if ($result < 0)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
*/
|
||||
if ($action == 'setmode' && $user->rights->commande->creer)
|
||||
if ($action == 'setdeliveryaddress' && $user->rights->commande->creer)
|
||||
{
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
$object->setDeliveryAddress(GETPOST('delivery_address_id','int'));
|
||||
if ($result < 0)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
*/
|
||||
if ($action == 'setmode' && $user->rights->commande->creer) {
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setavailability' && $user->rights->commande->creer) {
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$result = $object->availability(GETPOST('availability_id'));
|
||||
if ($result < 0)
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setdemandreason' && $user->rights->commande->creer) {
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$result = $object->demand_reason(GETPOST('demand_reason_id'));
|
||||
if ($result < 0)
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setconditions' && $user->rights->commande->creer)
|
||||
{
|
||||
if ($action == 'setconditions' && $user->rights->commande->creer) {
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
||||
if ($result < 0)
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
// Set incoterm
|
||||
elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
|
||||
{
|
||||
}
|
||||
} elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) {
|
||||
// Set incoterm
|
||||
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -172,8 +173,9 @@ if (empty($reshook))
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
|
||||
if ($result < 0)
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// warehouse
|
||||
@ -181,35 +183,35 @@ if (empty($reshook))
|
||||
$object = new Commande($db);
|
||||
$object->fetch($id);
|
||||
$result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
|
||||
if ($result < 0)
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'update_extras')
|
||||
{
|
||||
if ($action == 'update_extras') {
|
||||
$object->oldcopy = dol_clone($object);
|
||||
|
||||
// Fill array 'array_options' with data from update form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
|
||||
if ($ret < 0) $error++;
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// Actions on extra fields
|
||||
$result = $object->insertExtraFields('SHIPMENT_MODIFY');
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error)
|
||||
if ($error) {
|
||||
$action = 'edit_extras';
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'set_thirdparty' && $user->rights->commande->creer)
|
||||
{
|
||||
if ($action == 'set_thirdparty' && $user->rights->commande->creer) {
|
||||
$object->fetch($id);
|
||||
$object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY');
|
||||
|
||||
@ -227,16 +229,16 @@ if (empty($reshook))
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formproduct = new FormProduct($db);
|
||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
}
|
||||
|
||||
llxHeader('', $langs->trans('OrderCard'), '');
|
||||
|
||||
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object = new Commande($db);
|
||||
if ($object->fetch($id, $ref) > 0)
|
||||
{
|
||||
if ($object->fetch($id, $ref) > 0) {
|
||||
$object->loadExpeditions(1);
|
||||
|
||||
$product_static = new Product($db);
|
||||
@ -256,16 +258,18 @@ if ($id > 0 || !empty($ref))
|
||||
$formconfirm = '';
|
||||
|
||||
// Confirm validation
|
||||
if ($action == 'cloture')
|
||||
{
|
||||
if ($action == 'cloture') {
|
||||
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id, $langs->trans("CloseShipment"), $langs->trans("ConfirmCloseShipment"), "confirm_cloture");
|
||||
}
|
||||
|
||||
// Call Hook formConfirm
|
||||
$parameters = array('formConfirm' => $formconfirm);
|
||||
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
|
||||
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
|
||||
if (empty($reshook)) {
|
||||
$formconfirm .= $hookmanager->resPrint;
|
||||
} elseif ($reshook > 0) {
|
||||
$formconfirm = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
// Print form confirm
|
||||
print $formconfirm;
|
||||
@ -283,12 +287,10 @@ if ($id > 0 || !empty($ref))
|
||||
// Thirdparty
|
||||
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1);
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled))
|
||||
{
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||
if ($user->rights->commande->creer)
|
||||
{
|
||||
if ($user->rights->commande->creer) {
|
||||
if ($action != 'classify') {
|
||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
||||
}
|
||||
@ -366,11 +368,12 @@ if ($id > 0 || !empty($ref))
|
||||
print $langs->trans('DateDeliveryPlanned');
|
||||
print '</td>';
|
||||
|
||||
if ($action != 'editdate_livraison') print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'</a></td>';
|
||||
if ($action != 'editdate_livraison') {
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($action == 'editdate_livraison')
|
||||
{
|
||||
if ($action == 'editdate_livraison') {
|
||||
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="setdatedelivery">';
|
||||
@ -395,8 +398,9 @@ if ($id > 0 || !empty($ref))
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('SendingMethod');
|
||||
print '</td>';
|
||||
if ($action != 'editshippingmethod' && $user->rights->expedition->creer)
|
||||
if ($action != 'editshippingmethod' && $user->rights->expedition->creer) {
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($action == 'editshippingmethod') {
|
||||
@ -415,8 +419,9 @@ if ($id > 0 || !empty($ref))
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('Warehouse');
|
||||
print '</td>';
|
||||
if ($action != 'editwarehouse' && $user->rights->commande->creer)
|
||||
if ($action != 'editwarehouse' && $user->rights->commande->creer) {
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editwarehouse&id='.$object->id.'">'.img_edit($langs->trans('SetWarehouse'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($action == 'editwarehouse') {
|
||||
@ -471,8 +476,9 @@ if ($id > 0 || !empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('AvailabilityPeriod');
|
||||
print '</td>';
|
||||
if ($action != 'editavailability')
|
||||
if ($action != 'editavailability') {
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editavailability&id='.$object->id.'">'.img_edit($langs->trans('SetAvailability'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($action == 'editavailability') {
|
||||
@ -487,8 +493,9 @@ if ($id > 0 || !empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Source');
|
||||
print '</td>';
|
||||
if ($action != 'editdemandreason')
|
||||
if ($action != 'editdemandreason') {
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&id='.$object->id.'">'.img_edit($langs->trans('SetDemandReason'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($action == 'editdemandreason') {
|
||||
@ -500,8 +507,7 @@ if ($id > 0 || !empty($ref))
|
||||
$tmparray = $object->getTotalWeightVolume();
|
||||
$totalWeight = $tmparray['weight'];
|
||||
$totalVolume = $tmparray['volume'];
|
||||
if ($totalWeight || $totalVolume)
|
||||
{
|
||||
if ($totalWeight || $totalVolume) {
|
||||
print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>';
|
||||
print '<td>';
|
||||
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no');
|
||||
@ -515,19 +521,20 @@ if ($id > 0 || !empty($ref))
|
||||
// TODO How record was recorded OrderMode (llx_c_input_method)
|
||||
|
||||
// Incoterms
|
||||
if (!empty($conf->incoterm->enabled))
|
||||
{
|
||||
if (!empty($conf->incoterm->enabled)) {
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('IncotermLabel');
|
||||
print '<td><td class="right">';
|
||||
if ($user->rights->commande->creer) print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'/expedition/shipment.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
|
||||
else print ' ';
|
||||
if ($user->rights->commande->creer) {
|
||||
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'/expedition/shipment.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
print '</td>';
|
||||
print '<td colspan="3">';
|
||||
if ($action != 'editincoterm')
|
||||
{
|
||||
if ($action != 'editincoterm') {
|
||||
print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
|
||||
} else {
|
||||
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id);
|
||||
@ -551,8 +558,7 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
|
||||
{
|
||||
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) {
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
|
||||
print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
|
||||
@ -579,13 +585,11 @@ if ($id > 0 || !empty($ref))
|
||||
print '</tr>';
|
||||
|
||||
// Amount Local Taxes
|
||||
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1
|
||||
{
|
||||
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1
|
||||
print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
|
||||
print '<td>'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
}
|
||||
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF
|
||||
{
|
||||
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 IRPF
|
||||
print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
|
||||
print '<td>'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
|
||||
}
|
||||
@ -627,8 +631,7 @@ if ($id > 0 || !empty($ref))
|
||||
//print $sql;
|
||||
dol_syslog("shipment.php", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
@ -637,8 +640,7 @@ if ($id > 0 || !empty($ref))
|
||||
print '<td class="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td class="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td class="center">'.$langs->trans("KeepToShip").'</td>';
|
||||
if (!empty($conf->stock->enabled))
|
||||
{
|
||||
if (!empty($conf->stock->enabled)) {
|
||||
print '<td class="center">'.$langs->trans("RealStock").'</td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
@ -647,32 +649,34 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
$toBeShipped = array();
|
||||
$toBeShippedTotal = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$parameters = array('i' => $i, 'line' => $objp, 'num' => $num);
|
||||
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Show product and description
|
||||
$type = isset($objp->type) ? $objp->type : $objp->product_type;
|
||||
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (!empty($objp->date_start)) $type = 1;
|
||||
if (!empty($objp->date_end)) $type = 1;
|
||||
if (!empty($objp->date_start)) {
|
||||
$type = 1;
|
||||
}
|
||||
if (!empty($objp->date_end)) {
|
||||
$type = 1;
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Product label
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
if ($objp->fk_product > 0) {
|
||||
// Define output language
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$prod = new Product($db);
|
||||
@ -682,16 +686,21 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
|
||||
if (empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (!empty($newlang))
|
||||
{
|
||||
if (empty($newlang) && !empty($_REQUEST['lang_id'])) {
|
||||
$newlang = $_REQUEST['lang_id'];
|
||||
}
|
||||
if (empty($newlang)) {
|
||||
$newlang = $object->thirdparty->default_lang;
|
||||
}
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
|
||||
} else $label = (!empty($objp->label) ? $objp->label : $objp->product_label);
|
||||
} else {
|
||||
$label = (!empty($objp->label) ? $objp->label : $objp->product_label);
|
||||
}
|
||||
|
||||
print '<td>';
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
@ -725,16 +734,18 @@ if ($id > 0 || !empty($ref))
|
||||
print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end));
|
||||
|
||||
// Add description in form
|
||||
if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
|
||||
{
|
||||
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
|
||||
print ($objp->description && $objp->description != $objp->product_label) ? '<br>'.dol_htmlentitiesbr($objp->description) : '';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
} else {
|
||||
print "<td>";
|
||||
if ($type == 1) $text = img_object($langs->trans('Service'), 'service');
|
||||
else $text = img_object($langs->trans('Product'), 'product');
|
||||
if ($type == 1) {
|
||||
$text = img_object($langs->trans('Service'), 'service');
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'), 'product');
|
||||
}
|
||||
|
||||
if (!empty($objp->label)) {
|
||||
$text .= ' <strong>'.$objp->label.'</strong>';
|
||||
@ -761,8 +772,7 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
// Qty remains to ship
|
||||
print '<td class="center">';
|
||||
if ($type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
{
|
||||
if ($type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
|
||||
$toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
|
||||
$toBeShippedTotal += $toBeShipped[$objp->fk_product];
|
||||
print $toBeShipped[$objp->fk_product];
|
||||
@ -771,19 +781,16 @@ if ($id > 0 || !empty($ref))
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
if ($objp->fk_product > 0) {
|
||||
$product = new Product($db);
|
||||
$product->fetch($objp->fk_product);
|
||||
$product->load_stock('warehouseopen');
|
||||
}
|
||||
|
||||
if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && !empty($conf->stock->enabled))
|
||||
{
|
||||
if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && !empty($conf->stock->enabled)) {
|
||||
print '<td class="center">';
|
||||
print $product->stock_reel;
|
||||
if ($product->stock_reel < $toBeShipped[$objp->fk_product])
|
||||
{
|
||||
if ($product->stock_reel < $toBeShipped[$objp->fk_product]) {
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '</td>';
|
||||
@ -793,8 +800,7 @@ if ($id > 0 || !empty($ref))
|
||||
print "</tr>\n";
|
||||
|
||||
// Show subproducts lines
|
||||
if ($objp->fk_product > 0 && !empty($conf->global->PRODUIT_SOUSPRODUITS))
|
||||
{
|
||||
if ($objp->fk_product > 0 && !empty($conf->global->PRODUIT_SOUSPRODUITS)) {
|
||||
// Set tree of subproducts in product->sousprods
|
||||
$product->get_sousproduits_arbo();
|
||||
//var_dump($product->sousprods);exit;
|
||||
@ -802,13 +808,10 @@ if ($id > 0 || !empty($ref))
|
||||
// Define a new tree with quantiies recalculated
|
||||
$prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
|
||||
//var_dump($prods_arbo);
|
||||
if (count($prods_arbo) > 0)
|
||||
{
|
||||
foreach ($prods_arbo as $key => $value)
|
||||
{
|
||||
if (count($prods_arbo) > 0) {
|
||||
foreach ($prods_arbo as $key => $value) {
|
||||
$img = '';
|
||||
if ($value['stock'] < $value['stock_alert'])
|
||||
{
|
||||
if ($value['stock'] < $value['stock_alert']) {
|
||||
$img = img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '<tr class="oddeven"><td> -> <a href="'.DOL_URL_ROOT."/product/card.php?id=".$value['id'].'">'.$value['fullpath'].'</a> ('.$value['nb'].')</td>';
|
||||
@ -824,8 +827,7 @@ if ($id > 0 || !empty($ref))
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
if (!$num)
|
||||
{
|
||||
if (!$num) {
|
||||
print '<tr '.$bc[false].'><td colspan="5">'.$langs->trans("NoArticleOfTypeProduct").'<br>';
|
||||
}
|
||||
|
||||
@ -841,18 +843,14 @@ if ($id > 0 || !empty($ref))
|
||||
* Boutons Actions
|
||||
*/
|
||||
|
||||
if (empty($user->socid))
|
||||
{
|
||||
if (empty($user->socid)) {
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Bouton expedier sans gestion des stocks
|
||||
if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED))
|
||||
{
|
||||
if ($user->rights->expedition->creer)
|
||||
{
|
||||
if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) {
|
||||
if ($user->rights->expedition->creer) {
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create&origin=commande&object_id='.$id.'">'.$langs->trans("CreateShipment").'</a>';
|
||||
if ($toBeShippedTotal <= 0)
|
||||
{
|
||||
if ($toBeShippedTotal <= 0) {
|
||||
print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
|
||||
}
|
||||
} else {
|
||||
@ -865,15 +863,12 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
// Bouton expedier avec gestion des stocks
|
||||
|
||||
if (!empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT)
|
||||
{
|
||||
if (!empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT) {
|
||||
print $langs->trans("ValidateOrderFirstBeforeShipment");
|
||||
}
|
||||
|
||||
if (!empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED))
|
||||
{
|
||||
if ($user->rights->expedition->creer)
|
||||
{
|
||||
if (!empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) {
|
||||
if ($user->rights->expedition->creer) {
|
||||
//print load_fiche_titre($langs->trans("CreateShipment"));
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
@ -890,23 +885,20 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
//print '<tr>';
|
||||
|
||||
if (!empty($conf->stock->enabled))
|
||||
{
|
||||
if (!empty($conf->stock->enabled)) {
|
||||
//print '<td>';
|
||||
print $langs->trans("WarehouseSource");
|
||||
//print '</td>';
|
||||
//print '<td>';
|
||||
print $formproduct->selectWarehouses(!empty($object->warehouse_id) ? $object->warehouse_id : 'ifone', 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200');
|
||||
if (count($formproduct->cache_warehouses) <= 0)
|
||||
{
|
||||
if (count($formproduct->cache_warehouses) <= 0) {
|
||||
print ' '.$langs->trans("WarehouseSourceNotDefined").' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create">'.$langs->trans("AddOne").'</a>';
|
||||
}
|
||||
//print '</td>';
|
||||
}
|
||||
//print '<td class="center">';
|
||||
print '<input type="submit" class="butAction" named="save" value="'.$langs->trans("CreateShipment").'">';
|
||||
if ($toBeShippedTotal <= 0)
|
||||
{
|
||||
if ($toBeShippedTotal <= 0) {
|
||||
print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
|
||||
}
|
||||
//print '</td></tr>';
|
||||
|
||||
@ -34,8 +34,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
|
||||
$userid = GETPOST('userid', 'int');
|
||||
$socid = GETPOST('socid', 'int');
|
||||
// Security check
|
||||
if ($user->socid > 0)
|
||||
{
|
||||
if ($user->socid > 0) {
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
}
|
||||
@ -71,8 +70,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
|
||||
// $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.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
} else {
|
||||
$filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png';
|
||||
@ -80,12 +78,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
|
||||
|
||||
$px1 = new DolGraph();
|
||||
$mesg = $px1->isGraphKo();
|
||||
if (!$mesg)
|
||||
{
|
||||
if (!$mesg) {
|
||||
$px1->SetData($data);
|
||||
$i = $startyear; $legend = array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
@ -111,36 +107,36 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
|
||||
|
||||
if (!$user->rights->societe->client->voir || $user->socid)
|
||||
{
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$year.'.png';
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px2 = new DolGraph();
|
||||
$mesg = $px2->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px2->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px2->SetLegend($legend);
|
||||
$px2->SetMaxValue($px2->GetCeilMaxValue());
|
||||
$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
|
||||
$px2->SetWidth($WIDTH);
|
||||
$px2->SetHeight($HEIGHT);
|
||||
$px2->SetYLabel($langs->trans("AmountOfShipments"));
|
||||
$px2->SetShading(3);
|
||||
$px2->SetHorizTickIncrement(1);
|
||||
$px2->mode='depth';
|
||||
$px2->SetTitle($langs->trans("AmountOfShipmentsByMonthHT"));
|
||||
$px2->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px2->SetLegend($legend);
|
||||
$px2->SetMaxValue($px2->GetCeilMaxValue());
|
||||
$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
|
||||
$px2->SetWidth($WIDTH);
|
||||
$px2->SetHeight($HEIGHT);
|
||||
$px2->SetYLabel($langs->trans("AmountOfShipments"));
|
||||
$px2->SetShading(3);
|
||||
$px2->SetHorizTickIncrement(1);
|
||||
$px2->mode='depth';
|
||||
$px2->SetTitle($langs->trans("AmountOfShipmentsByMonthHT"));
|
||||
|
||||
$px2->draw($filenameamount,$fileurlamount);
|
||||
$px2->draw($filenameamount,$fileurlamount);
|
||||
}
|
||||
*/
|
||||
|
||||
@ -149,36 +145,36 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
|
||||
|
||||
if (!$user->rights->societe->client->voir || $user->socid)
|
||||
{
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$user->id.'-'.$year.'.png';
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$year.'.png';
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px3 = new DolGraph();
|
||||
$mesg = $px3->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px3->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px3->SetLegend($legend);
|
||||
$px3->SetYLabel($langs->trans("AmountAverage"));
|
||||
$px3->SetMaxValue($px3->GetCeilMaxValue());
|
||||
$px3->SetMinValue($px3->GetFloorMinValue());
|
||||
$px3->SetWidth($WIDTH);
|
||||
$px3->SetHeight($HEIGHT);
|
||||
$px3->SetShading(3);
|
||||
$px3->SetHorizTickIncrement(1);
|
||||
$px3->mode='depth';
|
||||
$px3->SetTitle($langs->trans("AmountAverage"));
|
||||
$px3->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px3->SetLegend($legend);
|
||||
$px3->SetYLabel($langs->trans("AmountAverage"));
|
||||
$px3->SetMaxValue($px3->GetCeilMaxValue());
|
||||
$px3->SetMinValue($px3->GetFloorMinValue());
|
||||
$px3->SetWidth($WIDTH);
|
||||
$px3->SetHeight($HEIGHT);
|
||||
$px3->SetShading(3);
|
||||
$px3->SetHorizTickIncrement(1);
|
||||
$px3->mode='depth';
|
||||
$px3->SetTitle($langs->trans("AmountAverage"));
|
||||
|
||||
$px3->draw($filename_avg,$fileurl_avg);
|
||||
$px3->draw($filename_avg,$fileurl_avg);
|
||||
}
|
||||
*/
|
||||
|
||||
@ -191,7 +187,9 @@ foreach ($data as $val) {
|
||||
$arrayyears[$val['year']] = $val['year'];
|
||||
}
|
||||
}
|
||||
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
|
||||
if (!count($arrayyears)) {
|
||||
$arrayyears[$nowyear] = $nowyear;
|
||||
}
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
@ -228,8 +226,12 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
print '</td></tr>';
|
||||
// Year
|
||||
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
|
||||
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
|
||||
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
|
||||
if (!in_array($year, $arrayyears)) {
|
||||
$arrayyears[$year] = $year;
|
||||
}
|
||||
if (!in_array($nowyear, $arrayyears)) {
|
||||
$arrayyears[$nowyear] = $nowyear;
|
||||
}
|
||||
arsort($arrayyears);
|
||||
print $form->selectarray('year', $arrayyears, $year, 0);
|
||||
print '</td></tr>';
|
||||
@ -250,11 +252,9 @@ print '<td class="center">'.$langs->trans("AmountAverage").'</td>';*/
|
||||
print '</tr>';
|
||||
|
||||
$oldyear = 0;
|
||||
foreach ($data as $val)
|
||||
{
|
||||
foreach ($data as $val) {
|
||||
$year = $val['year'];
|
||||
while (!empty($year) && $oldyear > $year + 1)
|
||||
{ // If we have empty year
|
||||
while (!empty($year) && $oldyear > $year + 1) { // If we have empty year
|
||||
$oldyear--;
|
||||
|
||||
|
||||
@ -292,12 +292,14 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
// Show graphs
|
||||
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
|
||||
if ($mesg) { print $mesg; } else {
|
||||
if ($mesg) {
|
||||
print $mesg;
|
||||
} else {
|
||||
print $px1->show();
|
||||
print "<br>\n";
|
||||
/*print $px2->show();
|
||||
print "<br>\n";
|
||||
print $px3->show();*/
|
||||
print "<br>\n";
|
||||
print $px3->show();*/
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
|
||||
@ -324,17 +326,17 @@ $sql.= " GROUP BY dm DESC";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$nbproduct = $row[0];
|
||||
$year = $row[1];
|
||||
print "<tr>";
|
||||
print '<td class="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td class="center">'.$nbproduct.'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$nbproduct = $row[0];
|
||||
$year = $row[1];
|
||||
print "<tr>";
|
||||
print '<td class="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td class="center">'.$nbproduct.'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
|
||||
@ -17,8 +17,7 @@
|
||||
*/
|
||||
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($conf) || !is_object($conf))
|
||||
{
|
||||
if (empty($conf) || !is_object($conf)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit;
|
||||
}
|
||||
@ -37,48 +36,49 @@ $langs->load("sendings");
|
||||
|
||||
$total = 0;
|
||||
$ilink = 0;
|
||||
foreach ($linkedObjectBlock as $key => $objectlink)
|
||||
{
|
||||
foreach ($linkedObjectBlock as $key => $objectlink) {
|
||||
$ilink++;
|
||||
|
||||
$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';
|
||||
}
|
||||
?>
|
||||
<tr class="<?php echo $trclass; ?>">
|
||||
<td><?php echo $langs->trans("Shipment"); ?></td>
|
||||
<td><?php echo $objectlink->getNomUrl(1); ?></td>
|
||||
<td></td>
|
||||
<td class="center"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td>
|
||||
<td class="right"><?php
|
||||
<tr class="<?php echo $trclass; ?>">
|
||||
<td><?php echo $langs->trans("Shipment"); ?></td>
|
||||
<td><?php echo $objectlink->getNomUrl(1); ?></td>
|
||||
<td></td>
|
||||
<td class="center"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td>
|
||||
<td class="right"><?php
|
||||
if ($user->rights->expedition->lire) {
|
||||
$total = $total + $objectlink->total_ht;
|
||||
echo price($objectlink->total_ht);
|
||||
} ?></td>
|
||||
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
|
||||
<td class="right">
|
||||
<?php
|
||||
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
|
||||
<td class="right">
|
||||
<?php
|
||||
// For now, shipments must stay linked to order, so link is not deletable
|
||||
if ($object->element != 'commande') {
|
||||
?>
|
||||
<a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
|
||||
<?php
|
||||
<a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
if (count($linkedObjectBlock) > 1) {
|
||||
?>
|
||||
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
|
||||
<td><?php echo $langs->trans("Total"); ?></td>
|
||||
<td></td>
|
||||
<td class="center"></td>
|
||||
<td class="center"></td>
|
||||
<td class="right"><?php echo price($total); ?></td>
|
||||
<td class="right"></td>
|
||||
<td class="right"></td>
|
||||
</tr>
|
||||
<?php
|
||||
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
|
||||
<td><?php echo $langs->trans("Total"); ?></td>
|
||||
<td></td>
|
||||
<td class="center"></td>
|
||||
<td class="center"></td>
|
||||
<td class="right"><?php echo price($total); ?></td>
|
||||
<td class="right"></td>
|
||||
<td class="right"></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
print "<!-- END PHP TEMPLATE -->\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user