From ae180f06a03572412189f94445a5bead7d1135cf Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 00:53:46 +0100 Subject: [PATCH 1/7] Fix : document module option was not saved --- htdocs/admin/propal.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 6c18da0e240..755ca681c73 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -162,10 +162,34 @@ if ($action == 'setdefaultduration') } } -/*if ($action == 'setusecustomercontactasrecipient') +// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) +if ($action == 'setModuleOptions') { - dolibarr_set_const($db, "PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT",$_POST["value"],'chaine',0,'',$conf->entity); -}*/ + $post_size=count($_POST); + + $db->begin(); + + for($i=0;$i < $post_size;$i++) + { + if (array_key_exists('param'.$i,$_POST)) + { + $param=GETPOST("param".$i,'alpha'); + $value=GETPOST("value".$i,'alpha'); + if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + } + if (! $error) + { + $db->commit(); + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $db->rollback(); + $mesg = "".$langs->trans("Error").""; + } +} From 5f1141675c4347562c39db9423d88d99cd21aae8 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 01:10:21 +0100 Subject: [PATCH 2/7] Add constants into config of ODT document for propal : can choose wich ODT will be used on creation and when close to bill or not. --- .../doc/doc_generic_proposal_odt.modules.php | 32 ++++++++++++++++++- htdocs/langs/fr_FR/propal.lang | 3 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 0f9e64c1fe2..54cf9efb2cc 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -106,6 +106,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales $texte.= ''; $texte.= ''; $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; $texte.= ''; // List of directories area @@ -143,8 +146,35 @@ class doc_generic_proposal_odt extends ModelePDFPropales $texte.= '
'; // Scan directories - if (count($listofdir)) $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + if (count($listofdir)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + + // Model for creation + $liste=ModelePDFPropales::liste_modeles($this->db); + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '"; + + $texte.= ''; + $texte.= ''; + $texte.= '"; + $texte.= ''; + + $texte.= ''; + $texte.= '"; + $texte.= '
'.$langs->trans("DefaultModelPropalCreate").''; + $texte.= $form->selectarray('value2',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT); + $texte.= "
'.$langs->trans("DefaultModelPropalToBill").''; + $texte.= $form->selectarray('value3',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL); + $texte.= "
'.$langs->trans("DefaultModelPropalCreate").''; + $texte.= $form->selectarray('value4',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); + $texte.= "
'; + } + + $texte.= ''; diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index 5a4c05f0d6d..5d5d1b2043c 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -97,4 +97,7 @@ TypeContact_propal_external_CUSTOMER=Contact client suivi propale DocModelAzurDescription=Modèle de propositions commerciales complet (logo...) DocModelJauneDescription=Modèle de proposition Jaune Numbershort=N° +DefaultModelPropalCreate=Modèle par défaut à la création +DefaultModelPropalToBill=Modèle lors de la cloture d'une proposition commerciale (à facturer) +DefaultModelPropalClosed=Modèle lors de la cloture d'une proposition commerciale (non facturée) From 8a3fae31e1850e9c3120f0715cfc5f1c9cc5fb01 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 01:13:44 +0100 Subject: [PATCH 3/7] When create a propal, select model document chosen by defaut in module config --- htdocs/comm/propal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e17940379bf..11a78523189 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1331,7 +1331,7 @@ if ($action == 'create') print ''.$langs->trans("DefaultModel").''; print ''; $liste=ModelePDFPropales::liste_modeles($db); - print $form->selectarray('model',$liste,$conf->global->PROPALE_ADDON_PDF); + print $form->selectarray('model',$liste,($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT?$conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT:$conf->global->PROPALE_ADDON_PDF)); print ""; // Project From 65a9edd5a7795642a120c8827daa53e40ba7379b Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 01:52:56 +0100 Subject: [PATCH 4/7] Fix : lang --- .../modules/propale/doc/doc_generic_proposal_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 54cf9efb2cc..959d9b29cd9 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -166,7 +166,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $texte.= ""; $texte.= ''; - $texte.= ''.$langs->trans("DefaultModelPropalCreate").''; + $texte.= ''.$langs->trans("DefaultModelPropalClosed").''; $texte.= ''; $texte.= $form->selectarray('value4',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); $texte.= ""; From 71bb4149cc250800623a32bd910088123796d1e2 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 02:08:07 +0100 Subject: [PATCH 5/7] New : Automatic creation of the document to the closing of the propale depending on the model selected in the configuration --- htdocs/comm/propal/class/propal.class.php | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 66f6bb3874d..a7cc2f71c2b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1634,6 +1634,20 @@ class Propal extends CommonObject $this->db->rollback(); return -2; } + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; @@ -1646,6 +1660,21 @@ class Propal extends CommonObject } else { + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); From 1f537300ea11e8c85a2c3d89015cd75834d53179 Mon Sep 17 00:00:00 2001 From: jfefe Date: Wed, 27 Mar 2013 19:11:42 +0100 Subject: [PATCH 6/7] Add hidden option MAIN_PROPAL_CHOOSE_ODT_DOCUMENT to enable choice of ODT document to use according to his status --- .../doc/doc_generic_proposal_odt.modules.php | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 959d9b29cd9..0878e4da181 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -106,9 +106,12 @@ class doc_generic_proposal_odt extends ModelePDFPropales $texte.= ''; $texte.= ''; $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) + { + $texte.= ''; + $texte.= ''; + $texte.= ''; + } $texte.= ''; // List of directories area @@ -150,27 +153,30 @@ class doc_generic_proposal_odt extends ModelePDFPropales { $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; - // Model for creation - $liste=ModelePDFPropales::liste_modeles($this->db); - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= '"; - - $texte.= ''; - $texte.= ''; - $texte.= '"; - $texte.= ''; - - $texte.= ''; - $texte.= '"; - $texte.= '
'.$langs->trans("DefaultModelPropalCreate").''; - $texte.= $form->selectarray('value2',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT); - $texte.= "
'.$langs->trans("DefaultModelPropalToBill").''; - $texte.= $form->selectarray('value3',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL); - $texte.= "
'.$langs->trans("DefaultModelPropalClosed").''; - $texte.= $form->selectarray('value4',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); - $texte.= "
'; + if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) + { + // Model for creation + $liste=ModelePDFPropales::liste_modeles($this->db); + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '"; + + $texte.= ''; + $texte.= ''; + $texte.= '"; + $texte.= ''; + + $texte.= ''; + $texte.= '"; + $texte.= '
'.$langs->trans("DefaultModelPropalCreate").''; + $texte.= $form->selectarray('value2',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT); + $texte.= "
'.$langs->trans("DefaultModelPropalToBill").''; + $texte.= $form->selectarray('value3',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL); + $texte.= "
'.$langs->trans("DefaultModelPropalClosed").''; + $texte.= $form->selectarray('value4',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); + $texte.= "
'; + } } From 1f5987b379a232498f504f1fc8cd8f7c4692dc77 Mon Sep 17 00:00:00 2001 From: jfefe Date: Wed, 27 Mar 2013 19:13:50 +0100 Subject: [PATCH 7/7] Fix trad & add english --- htdocs/langs/en_US/propal.lang | 3 +++ htdocs/langs/fr_FR/propal.lang | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 197a9f52146..a5f01c3e884 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -96,3 +96,6 @@ TypeContact_propal_external_CUSTOMER=Customer contact following-up proposal # Document models DocModelAzurDescription=A complete proposal model (logo...) DocModelJauneDescription=Jaune proposal model +DefaultModelPropalCreate=Default model creation +DefaultModelPropalToBill=Default template when closing a business proposal (to be invoiced) +DefaultModelPropalClosed=Default template when closing a business proposal (unbilled) diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index 5d5d1b2043c..5a52f3b442b 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -98,6 +98,6 @@ DocModelAzurDescription=Modèle de propositions commerciales complet (logo...) DocModelJauneDescription=Modèle de proposition Jaune Numbershort=N° DefaultModelPropalCreate=Modèle par défaut à la création -DefaultModelPropalToBill=Modèle lors de la cloture d'une proposition commerciale (à facturer) -DefaultModelPropalClosed=Modèle lors de la cloture d'une proposition commerciale (non facturée) +DefaultModelPropalToBill=Modèle par défaut lors de la cloture d'une proposition commerciale (à facturer) +DefaultModelPropalClosed=Modèle par défaut lors de la cloture d'une proposition commerciale (non facturée)