From 7e02e3faf66d0f932bdee2947490014be07ac5f0 Mon Sep 17 00:00:00 2001 From: simnandez Date: Tue, 13 Mar 2012 17:28:55 +0100 Subject: [PATCH] New: [ task #156 ] Create an invoice from a delivery receipt --- htdocs/expedition/class/expedition.class.php | 34 ++++++++++++++++++- htdocs/expedition/fiche.php | 15 ++++++-- .../install/mysql/migration/3.1.0-3.2.0.sql | 3 +- .../install/mysql/tables/llx_expedition.sql | 1 - htdocs/langs/ca_ES/sendings.lang | 2 ++ htdocs/langs/en_US/sendings.lang | 2 ++ htdocs/langs/es_ES/sendings.lang | 2 ++ htdocs/langs/fr_FR/sendings.lang | 2 ++ 8 files changed, 55 insertions(+), 6 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 27c8ba6b5c1..991959809ec 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -56,6 +56,7 @@ class Expedition extends CommonObject var $tracking_number; var $tracking_url; var $statut; + var $billed; var $trueWeight; var $weight_units; @@ -95,6 +96,7 @@ class Expedition extends CommonObject $this->statuts[-1] = 'StatusSendingCanceled'; $this->statuts[0] = 'StatusSendingDraft'; $this->statuts[1] = 'StatusSendingValidated'; + $this->statuts[2] = 'StatusSendingProcessed'; } /** @@ -371,6 +373,7 @@ class Expedition extends CommonObject $this->tracking_number = $obj->tracking_number; $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility $this->origin_id = $obj->origin_id; + $this->billed = ($obj->fk_statut==2?1:0); $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; @@ -988,27 +991,32 @@ class Expedition extends CommonObject if ($mode==0) { if ($statut==0) return $langs->trans($this->statuts[$statut]); - if ($statut==1) return $langs->trans($this->statuts[$statut]); + if ($statut==1) return $langs->trans($this->statuts[$statut]); + if ($statut==2) return $langs->trans($this->statuts[$statut]); } if ($mode==1) { if ($statut==0) return $langs->trans('StatusSendingDraftShort'); if ($statut==1) return $langs->trans('StatusSendingValidatedShort'); + if ($statut==2) return $langs->trans('StatusSendingProcessedShort'); } if ($mode == 3) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0'); if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4'); + if ($statut==2) return img_picto($langs->trans('StatusSendingProcessed'),'statut6'); } if ($mode == 4) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); + if ($statut==2) return img_picto($langs->trans('StatusSendingProcessed'),'statut6').' '.$langs->trans('StatusSendingProcessed'); } if ($mode == 5) { if ($statut==0) return $langs->trans('StatusSendingDraftShort').' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); if ($statut==1) return $langs->trans('StatusSendingValidatedShort').' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); + if ($statut==2) return $langs->trans('StatusSendingProcessedShort').' '.img_picto($langs->trans('StatusSendingProcessedShort'),'statut6'); } } @@ -1201,6 +1209,30 @@ class Expedition extends CommonObject $this->tracking_url = $value; } } + + /** + * Classify the shipping as invoiced + * + * @return int <0 if ko, >0 if ok + */ + function set_billed() + { + global $conf; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; + if ($this->db->query($sql) ) + { + //TODO: Option to set order billed if 100% of order is shipped + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } + } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 2abc70b3f71..8ce041038dd 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -505,6 +505,11 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile' } } +if ($action == 'classifybilled') +{ + $object->fetch($id); + $object->set_billed(); +} /* * View @@ -1296,7 +1301,7 @@ else }*/ // Send - if ($object->statut == 1) + if ($object->statut > 0) { $ref = dol_sanitizeFileName($object->ref); $file = $conf->expedition->dir_output . '/sending/'.$ref.'/'.$ref.'.pdf'; @@ -1321,7 +1326,7 @@ else } // TODO add alternative status - if ($user->rights->expedition->creer && $object->statut > 2) + if ($user->rights->expedition->creer && $object->statut > 0) { print ''.$langs->trans("ClassifyBilled").''; } @@ -1360,6 +1365,12 @@ else //$delallowed=0; $somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); + + /* + * Linked object block + */ + $somethingshown=$object->showLinkedObjectBlock(); + if ($genallowed && ! $somethingshown) $somethingshown=1; print ''; diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index 8f44d4a263f..548aa72f1c3 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -425,5 +425,4 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MXP' ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_currency FOREIGN KEY (fk_currency) REFERENCES llx_c_currencies (code_iso); ALTER TABLE llx_commande ADD CONSTRAINT fk_commande_fk_currency FOREIGN KEY (fk_currency) REFERENCES llx_c_currencies (code_iso); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_currency FOREIGN KEY (fk_currency) REFERENCES llx_c_currencies (code_iso); - -ALTER TABLE llx_expedition ADD COLUMN billed tinyint DEFAULT 0 AFTER fk_statut; \ No newline at end of file + \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_expedition.sql b/htdocs/install/mysql/tables/llx_expedition.sql index ba610418293..9296395b120 100644 --- a/htdocs/install/mysql/tables/llx_expedition.sql +++ b/htdocs/install/mysql/tables/llx_expedition.sql @@ -41,7 +41,6 @@ create table llx_expedition fk_expedition_methode integer, tracking_number varchar(50), fk_statut smallint DEFAULT 0, - billed tinyint DEFAULT 0, height integer, width integer, diff --git a/htdocs/langs/ca_ES/sendings.lang b/htdocs/langs/ca_ES/sendings.lang index 1744980e514..70facdbf280 100644 --- a/htdocs/langs/ca_ES/sendings.lang +++ b/htdocs/langs/ca_ES/sendings.lang @@ -31,9 +31,11 @@ SendingsToValidate=Enviaments a validar StatusSendingCanceled=Anul.lat StatusSendingDraft=Esborrany StatusSendingValidated=Validat (productes a enviar o enviats) +StatusSendingProcessed=Processat StatusSendingCanceledShort=Anul.lat StatusSendingDraftShort=Esborrany StatusSendingValidatedShort=Validat +StatusSendingProcessedShort=Processat SendingSheet=Nota de lliurament Carriers=Transportistes Carrier=Transportista diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index de1af6be401..b43bff67777 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -31,9 +31,11 @@ SendingsToValidate=Shipments to validate StatusSendingCanceled=Canceled StatusSendingDraft=Draft StatusSendingValidated=Validated (products to ship or already shipped) +StatusSendingProcessed=Processed StatusSendingCanceledShort=Canceled StatusSendingDraftShort=Draft StatusSendingValidatedShort=Validated +StatusSendingProcessedShort=Processed SendingSheet=Sending sheet Carriers=Carriers Carrier=Carrier diff --git a/htdocs/langs/es_ES/sendings.lang b/htdocs/langs/es_ES/sendings.lang index fc8268cf1b3..861c49439dd 100644 --- a/htdocs/langs/es_ES/sendings.lang +++ b/htdocs/langs/es_ES/sendings.lang @@ -31,9 +31,11 @@ SendingsToValidate=Envíos a validar StatusSendingCanceled=Anulado StatusSendingDraft=Borrador StatusSendingValidated=Validado (productos a enviar o enviados) +StatusSendingProcessed=Procesado StatusSendingCanceledShort=Anulado StatusSendingDraftShort=Borrador StatusSendingValidatedShort=Validado +StatusSendingProcessedShort=Procesado SendingSheet=Nota de entrega Carriers=Transportistas Carrier=Transportista diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index f2a5e9cb2b0..f703323ad04 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -31,9 +31,11 @@ SendingsToValidate=Expéditions à valider StatusSendingCanceled=Annulée StatusSendingDraft=Brouillon StatusSendingValidated=Validée (produits à envoyer ou envoyés) +StatusSendingProcessed=Traitée StatusSendingCanceledShort=Annulée StatusSendingDraftShort=Brouillon StatusSendingValidatedShort=Validée +StatusSendingProcessedShort=Traitée SendingSheet=Bordereau d'expédition Carriers=Transporteurs Carrier=Transporteur