Merge pull request #851 from FHenry/develop
Add hidden option MAIN_ODT_AS_PDF to save ODT as PDF
This commit is contained in:
commit
9c11b6a246
@ -794,6 +794,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Standard or deposit or proforma invoice
|
// Standard or deposit or proforma invoice
|
||||||
if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0)
|
if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0)
|
||||||
{
|
{
|
||||||
@ -872,6 +874,76 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
|
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
|
//If deposit invoice
|
||||||
|
if ($_POST['type'] == 3) {
|
||||||
|
$typeamount=GETPOST('typedeposit','alpha');
|
||||||
|
$valuedeposit=GETPOST('valuedeposit','int');
|
||||||
|
|
||||||
|
if ($typeamount=='amount') {
|
||||||
|
$amountdeposit=$valuedeposit;
|
||||||
|
}else {
|
||||||
|
$amountdeposit=0;
|
||||||
|
|
||||||
|
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||||
|
|
||||||
|
$classname = ucfirst($subelement);
|
||||||
|
$srcobject = new $classname($db);
|
||||||
|
|
||||||
|
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add deposit line");
|
||||||
|
$result=$srcobject->fetch($object->origin_id);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$totalamount=0;
|
||||||
|
$lines = $srcobject->lines;
|
||||||
|
$num=count($lines);
|
||||||
|
for ($i=0;$i<$num;$i++)
|
||||||
|
{
|
||||||
|
$totalamount=+$lines[$i]->subprice;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($totalamount!=0) {
|
||||||
|
$amountdeposit=($totalamount*$valuedeposit)/100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesgs[]=$srcobject->error;
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $object->addline(
|
||||||
|
$id,
|
||||||
|
$langs->trans('Deposit'),
|
||||||
|
$amountdeposit, //subprice
|
||||||
|
1, //quantity
|
||||||
|
$lines[$i]->tva_tx,
|
||||||
|
0, //localtax1_tx
|
||||||
|
0, //localtax2_tx
|
||||||
|
0, //fk_product
|
||||||
|
0, //remise_percent
|
||||||
|
0, //date_start
|
||||||
|
0, //date_end
|
||||||
|
0,
|
||||||
|
$lines[$i]->info_bits, //info_bits
|
||||||
|
0, //info_bits
|
||||||
|
'HT',
|
||||||
|
0,
|
||||||
|
0, //product_type
|
||||||
|
1,
|
||||||
|
$lines[$i]->special_code,
|
||||||
|
$object->origin,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$langs->trans('Deposit')
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
}else {
|
||||||
|
|
||||||
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||||
|
|
||||||
$classname = ucfirst($subelement);
|
$classname = ucfirst($subelement);
|
||||||
@ -994,6 +1066,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesgs[]=$object->error;
|
$mesgs[]=$object->error;
|
||||||
@ -2039,14 +2112,20 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($origin))
|
if ((empty($origin)) || (($origin=='propal') && (!empty($originid))))
|
||||||
{
|
{
|
||||||
// Deposit
|
// Deposit
|
||||||
print '<tr height="18"><td width="16px" valign="middle">';
|
print '<tr height="18"><td width="16px" valign="middle">';
|
||||||
print '<input type="radio" name="type" value="3"'.(GETPOST('type')==3?' checked="checked"':'').'>';
|
print '<input type="radio" name="type" value="3"'.(GETPOST('type')==3?' checked="checked"':'').'>';
|
||||||
print '</td><td valign="middle">';
|
print '</td><td valign="middle" nowrap="nowrap">';
|
||||||
$desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1);
|
$desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1);
|
||||||
print $desc;
|
print '<table class="nobordernopadding"><tr><td>'.$desc.'</td>';
|
||||||
|
if (($origin=='propal') ) {
|
||||||
|
print '<td><select name="typedeposit"><option value="amount">'.$langs->trans('FixAmount').'</option>';
|
||||||
|
print '<option value="variable">'.$langs->trans('VarAmount').'</option></select></td>';
|
||||||
|
print '<td>'.$langs->trans('Value').':<input type="text" name="valuedeposit" size="3" value="'.GETPOST('valuedeposit','int').'"/>';
|
||||||
|
}
|
||||||
|
print '</td></tr></table>';
|
||||||
print '</td></tr>'."\n";
|
print '</td></tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,12 +100,9 @@ $sql = "SELECT f.rowid, f.ref_supplier, f.type, f.datef, f.libelle,";
|
|||||||
$sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,";
|
$sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,";
|
||||||
$sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,";
|
$sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,";
|
||||||
$sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,";
|
$sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,";
|
||||||
$sql.= " ct.accountancy_code_buy as account_tva, ct.recuperableonly,";
|
$sql.= " ct.accountancy_code_buy as account_tva, ct.recuperableonly";
|
||||||
$sql.= " ctl1.accountancy_code_buy as account_localtax1, ctl2.accountancy_code_buy as account_localtax2";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ctl1 ON fd.localtax1_tx = ctl1.localtax1 AND ctl1.fk_pays = '".$idpays."'";
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ctl2 ON fd.localtax2_tx = ctl2.localtax2 AND ctl2.fk_pays = '".$idpays."'";
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
|
||||||
$sql.= " JOIN ".MAIN_DB_PREFIX."facture_fourn f ON f.rowid = fd.fk_facture_fourn";
|
$sql.= " JOIN ".MAIN_DB_PREFIX."facture_fourn f ON f.rowid = fd.fk_facture_fourn";
|
||||||
$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc" ;
|
$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc" ;
|
||||||
@ -146,6 +143,11 @@ if ($result)
|
|||||||
$compta_localtax1 = (! empty($obj->account_localtax1)?$obj->account_localtax1:$langs->trans("CodeNotDef"));
|
$compta_localtax1 = (! empty($obj->account_localtax1)?$obj->account_localtax1:$langs->trans("CodeNotDef"));
|
||||||
$compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef"));
|
$compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef"));
|
||||||
|
|
||||||
|
$account_localtax1=getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc);
|
||||||
|
$compta_localtax1= (! empty($account_localtax1[2])?$account_localtax1[2]:$langs->trans("CodeNotDef"));
|
||||||
|
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc);
|
||||||
|
$compta_localtax2= (! empty($account_localtax2[2])?$account_localtax2[2]:$langs->trans("CodeNotDef"));
|
||||||
|
|
||||||
$tabfac[$obj->rowid]["date"] = $obj->datef;
|
$tabfac[$obj->rowid]["date"] = $obj->datef;
|
||||||
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier;
|
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier;
|
||||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||||
|
|||||||
@ -102,15 +102,12 @@ $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client,";
|
|||||||
$sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,";
|
$sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,";
|
||||||
$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,";
|
$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,";
|
||||||
$sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,";
|
$sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,";
|
||||||
$sql.= " ct.accountancy_code_sell as account_tva, ct.recuperableonly,";
|
$sql.= " ct.accountancy_code_sell as account_tva, ct.recuperableonly";
|
||||||
$sql.= " ctl1.accountancy_code_sell as account_localtax1, ctl2.accountancy_code_sell as account_localtax2";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet fd";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet fd";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
|
||||||
$sql.= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture";
|
$sql.= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture";
|
||||||
$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc";
|
$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ctl1 ON fd.localtax1_tx = ctl1.localtax1 AND ctl1.fk_pays = '".$idpays."'";
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ctl2 ON fd.localtax2_tx = ctl2.localtax2 AND ctl2.fk_pays = '".$idpays."'";
|
|
||||||
$sql.= " WHERE f.entity = ".$conf->entity;
|
$sql.= " WHERE f.entity = ".$conf->entity;
|
||||||
$sql.= " AND f.fk_statut > 0";
|
$sql.= " AND f.fk_statut > 0";
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
|
||||||
@ -129,6 +126,8 @@ if ($result)
|
|||||||
$tablocaltax2 = array();
|
$tablocaltax2 = array();
|
||||||
$tabttc = array();
|
$tabttc = array();
|
||||||
$tabcompany = array();
|
$tabcompany = array();
|
||||||
|
$account_localtax1=0;
|
||||||
|
$account_localtax2=0;
|
||||||
|
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$i=0;
|
$i=0;
|
||||||
@ -147,8 +146,11 @@ if ($result)
|
|||||||
}
|
}
|
||||||
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef"));
|
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef"));
|
||||||
$compta_tva = (! empty($obj->account_tva)?$obj->account_tva:$cpttva);
|
$compta_tva = (! empty($obj->account_tva)?$obj->account_tva:$cpttva);
|
||||||
$compta_localtax1 = (! empty($obj->account_localtax1)?$obj->account_localtax1:$langs->trans("CodeNotDef"));
|
|
||||||
$compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef"));
|
$account_localtax1=getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc);
|
||||||
|
$compta_localtax1= (! empty($account_localtax1[3])?$account_localtax1[3]:$langs->trans("CodeNotDef"));
|
||||||
|
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc);
|
||||||
|
$compta_localtax2= (! empty($account_localtax2[3])?$account_localtax2[3]:$langs->trans("CodeNotDef"));
|
||||||
|
|
||||||
//la ligne facture
|
//la ligne facture
|
||||||
$tabfac[$obj->rowid]["date"] = $obj->datef;
|
$tabfac[$obj->rowid]["date"] = $obj->datef;
|
||||||
|
|||||||
@ -2848,7 +2848,7 @@ function getLocalTaxesFromRate($vatrate, $local, $thirdparty)
|
|||||||
dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local." thirdparty id=".(is_object($thirdparty)?$thirdparty->id:''));
|
dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local." thirdparty id=".(is_object($thirdparty)?$thirdparty->id:''));
|
||||||
|
|
||||||
// Search local taxes
|
// Search local taxes
|
||||||
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
|
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type,t.accountancy_code_sell,t.accountancy_code_buy";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||||
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$thirdparty->country_code."'";
|
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$thirdparty->country_code."'";
|
||||||
$sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
|
$sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
|
||||||
@ -2857,9 +2857,9 @@ function getLocalTaxesFromRate($vatrate, $local, $thirdparty)
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if ($local == 1) return array($obj->localtax1_type, $obj->localtax1);
|
if ($local == 1) return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||||
elseif ($local == 2) return array($obj->localtax2_type, $obj->localtax2);
|
elseif ($local == 2) return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||||
else return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2);
|
else return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -519,8 +519,12 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
//$result=$odfHandler->exportAsAttachedFile('toto');
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
|
|||||||
@ -497,8 +497,12 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
//$result=$odfHandler->exportAsAttachedFile('toto');
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
|
|||||||
@ -650,7 +650,7 @@ class doc_generic_project_odt extends ModelePDFProjects
|
|||||||
|
|
||||||
//Time ressources
|
//Time ressources
|
||||||
$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
|
$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
|
||||||
$sql.= ", u.name, u.firstname";
|
$sql.= ", u.lastname, u.firstname";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
|
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
|
||||||
$sql .= " , ".MAIN_DB_PREFIX."user as u";
|
$sql .= " , ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql .= " WHERE t.fk_task =".$task->id;
|
$sql .= " WHERE t.fk_task =".$task->id;
|
||||||
@ -973,8 +973,12 @@ class doc_generic_project_odt extends ModelePDFProjects
|
|||||||
|
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
//$odfHandler->exportAsAttachedPDF($file);
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
|
|||||||
@ -482,8 +482,12 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
//$result=$odfHandler->exportAsAttachedFile('toto');
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
|
|||||||
@ -313,8 +313,12 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
//$result=$odfHandler->exportAsAttachedFile('toto');
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
|
|||||||
@ -448,25 +448,62 @@ IMG;
|
|||||||
*/
|
*/
|
||||||
public function exportAsAttachedPDF($name="")
|
public function exportAsAttachedPDF($name="")
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
if( $name == "" ) $name = md5(uniqid());
|
if( $name == "" ) $name = md5(uniqid());
|
||||||
|
|
||||||
$this->saveToDisk("$name.odt");
|
//dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG);
|
||||||
exec("./odt2pdf.sh $name",$output,$ret_val);
|
$this->saveToDisk($name);
|
||||||
if($ret_val == 0)
|
|
||||||
|
$execmethod=(empty($conf->global->MAIN_EXEC_USE_POPEN)?1:2); // 1 or 2
|
||||||
|
|
||||||
|
$name=str_replace('.odt', '', $name);
|
||||||
|
$command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name;
|
||||||
|
//dol_syslog('$execmethod='.$execmethod.' Run command='.$command);
|
||||||
|
if ($execmethod == 1)
|
||||||
{
|
{
|
||||||
|
exec($command, $output_arr, $retval);
|
||||||
|
}
|
||||||
|
if ($execmethod == 2)
|
||||||
|
{
|
||||||
|
$ok=0;
|
||||||
|
$handle = fopen($outputfile, 'w');
|
||||||
|
if ($handle)
|
||||||
|
{
|
||||||
|
dol_syslog("Run command ".$command);
|
||||||
|
$handlein = popen($command, 'r');
|
||||||
|
while (!feof($handlein))
|
||||||
|
{
|
||||||
|
$read = fgets($handlein);
|
||||||
|
fwrite($handle,$read);
|
||||||
|
$output_arr[]=$read;
|
||||||
|
}
|
||||||
|
pclose($handlein);
|
||||||
|
fclose($handle);
|
||||||
|
}
|
||||||
|
if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($retval == 0)
|
||||||
|
{
|
||||||
|
//dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
|
||||||
if (headers_sent($filename, $linenum)) {
|
if (headers_sent($filename, $linenum)) {
|
||||||
throw new OdfException("headers already sent ($filename at $linenum)");
|
throw new OdfException("headers already sent ($filename at $linenum)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||||
header('Content-type: application/pdf');
|
header('Content-type: application/pdf');
|
||||||
header('Content-Disposition: attachment; filename="'.$name.'.pdf"');
|
header('Content-Disposition: attachment; filename="'.$name.'.pdf"');
|
||||||
readfile("$name.pdf");
|
readfile("$name.pdf");
|
||||||
|
}
|
||||||
unlink("$name.odt");
|
unlink("$name.odt");
|
||||||
unlink("$name.pdf");
|
|
||||||
} else {
|
} else {
|
||||||
|
//dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
|
||||||
|
//dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr,true), LOG_DEBUG);
|
||||||
echo "Error occured:<br>";
|
echo "Error occured:<br>";
|
||||||
foreach($output as $line)
|
foreach($output_arr as $line)
|
||||||
echo $line."<br>";
|
echo $line."<br>";
|
||||||
|
//dol_syslog(get_class($this).'::exportAsAttachedPDF ERROR $line='.$line, LOG_DEBUG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
htdocs/includes/odtphp/odt2pdf.sh
Normal file → Executable file
0
htdocs/includes/odtphp/odt2pdf.sh
Normal file → Executable file
@ -311,6 +311,8 @@ PaymentConditionShortPT_ORDER=On order
|
|||||||
PaymentConditionPT_ORDER=On order
|
PaymentConditionPT_ORDER=On order
|
||||||
PaymentConditionShortPT_5050=50-50
|
PaymentConditionShortPT_5050=50-50
|
||||||
PaymentConditionPT_5050=50%% in advance, 50%% on delivery
|
PaymentConditionPT_5050=50%% in advance, 50%% on delivery
|
||||||
|
FixAmount=Fix amount
|
||||||
|
VarAmount=Variable amount (%% tot.)
|
||||||
|
|
||||||
# PaymentType
|
# PaymentType
|
||||||
PaymentTypeVIR=Bank deposit
|
PaymentTypeVIR=Bank deposit
|
||||||
|
|||||||
@ -287,6 +287,8 @@ TotalOfTwoDiscountMustEqualsOriginal=La suma del importe de los 2 nuevos descuen
|
|||||||
ConfirmRemoveDiscount=¿Está seguro de querer eliminar este descuento?
|
ConfirmRemoveDiscount=¿Está seguro de querer eliminar este descuento?
|
||||||
RelatedBill=Factura asociada
|
RelatedBill=Factura asociada
|
||||||
RelatedBills=Facturas asociadas
|
RelatedBills=Facturas asociadas
|
||||||
|
FixAmount=Importe fijo
|
||||||
|
VarAmount=Importe variable (%% total)
|
||||||
|
|
||||||
# PaymentConditions
|
# PaymentConditions
|
||||||
PaymentConditionShortRECEP=A la recepción
|
PaymentConditionShortRECEP=A la recepción
|
||||||
|
|||||||
@ -322,6 +322,8 @@ PaymentTypeVAD=Paiement en ligne
|
|||||||
PaymentTypeShortVAD=Paiement en ligne
|
PaymentTypeShortVAD=Paiement en ligne
|
||||||
PaymentTypeTRA=Paiement par traite
|
PaymentTypeTRA=Paiement par traite
|
||||||
PaymentTypeShortTRA=Traite
|
PaymentTypeShortTRA=Traite
|
||||||
|
FixAmount=Montant Fixe
|
||||||
|
VarAmount=Montant variable (%% tot.)
|
||||||
|
|
||||||
BankDetails=Coordonnées bancaires
|
BankDetails=Coordonnées bancaires
|
||||||
BankCode=Code banque
|
BankCode=Code banque
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user