diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index c7940bb5450..21955fb9da4 100755 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -80,6 +80,7 @@ $workflowcodes=array(); $workflow=array( 'order' => array( 'propal' => array('WORKFLOW_PROPAL_AUTOCREATE_ORDER') + ,'invoice' => array('WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER') ), 'invoice' => array ( 'order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE') diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2fce0a684b8..1de92663642 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1654,8 +1654,21 @@ abstract class CommonObject $sql.= " WHERE "; if ($justsource || $justtarget) { +<<<<<<< OURS if ($justsource) $sql.= "fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."'"; if ($justtarget) $sql.= "fk_target = '".$targetid."' AND targettype = '".$targettype."'"; +======= + if ($justsource) + { + $sql.= "fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."'"; + if ($withtargettype) $sql.= " AND targettype = '".$targettype."'"; + } + else if ($justtarget) + { + $sql.= "fk_target = '".$targetid."' AND targettype = '".$targettype."'"; + if ($withsourcetype) $sql.= " AND sourcetype = '".$sourcetype."'"; + } +>>>>>>> THEIRS } else { diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 3c914faf0e1..3ba4b5b8248 100755 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -130,6 +130,42 @@ class InterfaceWorkflowManager } } + // Order classify billed proposal + if ($action == 'ORDER_CLASSIFY_BILLED') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if (! empty($conf->propal->enabled) && ! empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) + { + $object->fetchObjectLinked('','propal',$object->id,$object->element); + if (! empty($object->linkedObjects)) + { + foreach($object->linkedObjects['propal'] as $element) + { + $ret=$element->classifyBilled(); + } + } + return $ret; + } + } + + // Order classify billed proposal + if ($action == 'BILL_PAYED') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if (! empty($conf->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER)) + { + $object->fetchObjectLinked('','commande',$object->id,$object->element); + if (! empty($object->linkedObjects)) + { + foreach($object->linkedObjects['commande'] as $element) + { + $ret=$element->classifyBilled(); + } + } + return $ret; + } + } + return 0; } diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index bfdef03df19..c910cccc184 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -6,4 +6,6 @@ ThereIsNoWorkflowToModify=There is no workflow you can modify for module you hav descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Create a customer order automatically after a commercial proposal is signed descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Create a customer invoice automatically after a commercial proposal is signed descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Create a customer invoice automatically after a contract is validated -descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Create a customer invoice automatically after a customer order is closed \ No newline at end of file +descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Create a customer invoice automatically after a customer order is closed +descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify billed the original proposal along with a customer order +descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify billed originals customer orders along with a customer invoice diff --git a/htdocs/langs/fr_FR/workflow.lang b/htdocs/langs/fr_FR/workflow.lang index 06f59ea9e02..0702c0aebc3 100644 --- a/htdocs/langs/fr_FR/workflow.lang +++ b/htdocs/langs/fr_FR/workflow.lang @@ -6,4 +6,6 @@ ThereIsNoWorkflowToModify=Il n'y a pas de flux workflow modifiable pour les modu descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Créer une commande client automatiquement à la signature d'une proposition commerciale descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Créer une facture client automatiquement à la signature d'une proposition commerciale descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Créer une facture client automatiquement à la validation d'un contrat -descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Créer une facture client automatiquement à la cloture d'une commande client \ No newline at end of file +descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Créer une facture client automatiquement à la cloture d'une commande client +descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classer facturée la proposition commerciale d'origine en même temps que la commande +descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classer facturée la ou les commandes clients d'origine en même temps que la facture