Merge pull request #782 from jfefe/propal_odt_choice
New : can choose to generate the ODT document according to the status of a propale
This commit is contained in:
commit
07062065e5
@ -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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1331,7 +1331,7 @@ if ($action == 'create')
|
||||
print '<td>'.$langs->trans("DefaultModel").'</td>';
|
||||
print '<td colspan="2">';
|
||||
$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 "</td></tr>";
|
||||
|
||||
// Project
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -106,6 +106,12 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
|
||||
$texte.= '<input type="hidden" name="param1" value="PROPALE_ADDON_PDF_ODT_PATH">';
|
||||
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
|
||||
{
|
||||
$texte.= '<input type="hidden" name="param2" value="PROPALE_ADDON_PDF_ODT_DEFAULT">';
|
||||
$texte.= '<input type="hidden" name="param3" value="PROPALE_ADDON_PDF_ODT_TOBILL">';
|
||||
$texte.= '<input type="hidden" name="param4" value="PROPALE_ADDON_PDF_ODT_CLOSED">';
|
||||
}
|
||||
$texte.= '<table class="nobordernopadding" width="100%">';
|
||||
|
||||
// List of directories area
|
||||
@ -143,8 +149,38 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
$texte.= '</table>';
|
||||
|
||||
// Scan directories
|
||||
if (count($listofdir)) $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
|
||||
if (count($listofdir))
|
||||
{
|
||||
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
|
||||
|
||||
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
|
||||
{
|
||||
// Model for creation
|
||||
$liste=ModelePDFPropales::liste_modeles($this->db);
|
||||
$texte.= '<table width="50%;">';
|
||||
$texte.= '<tr>';
|
||||
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
|
||||
$texte.= '<td colspan="">';
|
||||
$texte.= $form->selectarray('value2',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT);
|
||||
$texte.= "</td></tr>";
|
||||
|
||||
$texte.= '<tr>';
|
||||
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
|
||||
$texte.= '<td colspan="">';
|
||||
$texte.= $form->selectarray('value3',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL);
|
||||
$texte.= "</td></tr>";
|
||||
$texte.= '<tr>';
|
||||
|
||||
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
|
||||
$texte.= '<td colspan="">';
|
||||
$texte.= $form->selectarray('value4',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED);
|
||||
$texte.= "</td></tr>";
|
||||
$texte.= '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$texte.= '</td>';
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 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)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user