forked from Wavyzz/dolibarr
work on going
This commit is contained in:
@@ -80,6 +80,7 @@ $workflowcodes=array(
|
||||
// For the following 2 options, if module invoice is disabled, they does not exists, so "Classify billed" for order must be done manually from order card.
|
||||
'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>40, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'),
|
||||
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>50, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'),
|
||||
'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
|
||||
);
|
||||
|
||||
if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
|
||||
|
||||
@@ -159,6 +159,61 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
}
|
||||
}
|
||||
|
||||
if ($action=='SHIPPING_VALIDATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
|
||||
if (! empty($conf->commande->enabled) && ! empty($conf->expedition->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING))
|
||||
{
|
||||
$qtyshipped=array();
|
||||
$qtyordred=array();
|
||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
|
||||
//find all shippement on order origin
|
||||
$order = new Commande($this->db);
|
||||
$ret=$order->fetch($this->origin_id);
|
||||
if ($ret<0) {
|
||||
$this->error=$order->error; $this->errors=$order->errors;
|
||||
return $ret;
|
||||
}
|
||||
var_dump($order);
|
||||
exit;
|
||||
$ret=$order->fetchObjectLinked($order->id,'commande',null,'shipping');
|
||||
if ($ret<0) {
|
||||
$this->error=$order->error; $this->errors=$order->errors;
|
||||
return $ret;
|
||||
}
|
||||
//Build array of quantity shipped by product for an order
|
||||
if (is_array($order->linkedObjects) && count($order->linkedObjects)>0) {
|
||||
foreach($order->linkedObjects as $shipping) {
|
||||
if (is_array($shipping->lines) && count($shipping->lines)>0) {
|
||||
foreach($shipping->lines as $shippingline) {
|
||||
$qtyshipped[$shippingline->fk_product]+=$shippingline->qty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Build array of quantity ordered by product
|
||||
if (is_array($order->lines) && count($order->lines)>0) {
|
||||
foreach($order->lines as $orderline) {
|
||||
$qtyordred[$orderline->fk_product]+=$orderline->qty;
|
||||
}
|
||||
}
|
||||
dol_syslog(var_export($qtyordred,true));
|
||||
dol_syslog(var_export($qtyshipped,true));
|
||||
//Compare array
|
||||
$diff_array=array_diff_assoc($qtyordred,$qtyshipped);
|
||||
if (count($diff_array)==0) {
|
||||
//No diff => mean everythings is shipped
|
||||
$ret=$object->setStatut(Commande::STATUS_CLOSED, $this->origin_id, $this->origin);
|
||||
if ($ret<0) {
|
||||
$this->error=$object->error; $this->errors=$object->errors;
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -732,8 +732,6 @@ class Expedition extends CommonObject
|
||||
return -2;
|
||||
}
|
||||
|
||||
// FIXME Set status of order to "delivered" if check box "set order as delivered if remain to ship is 0" is on and if sum of all validated shipment = products or order to ship (because we are in case of stock movement on shipment validation)
|
||||
|
||||
}
|
||||
|
||||
// Change status of order to "shipment in process"
|
||||
|
||||
@@ -10,3 +10,4 @@ descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to bil
|
||||
descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid
|
||||
descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is validated
|
||||
descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer invoice is validated
|
||||
descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify shipped linked source order on shipping validate if quantity shipped is the same as in order
|
||||
Reference in New Issue
Block a user