Skip to content

Commit

Permalink
Added odt support to supplier orders
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Otte committed Aug 27, 2019
1 parent 7cb68d6 commit 75152cb
Show file tree
Hide file tree
Showing 4 changed files with 544 additions and 0 deletions.
27 changes: 27 additions & 0 deletions htdocs/core/modules/modFournisseur.class.php
Expand Up @@ -111,6 +111,13 @@ public function __construct($db)
$this->const[$r][4] = 0;
$r++;

$this->const[$r][0] = "SUPPLIER_ORDER_ADDON_PDF_ODT_PATH";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_orders";
$this->const[$r][3] = '';
$this->const[$r][4] = 0;
$r++;

// Boxes
$this->boxes = array(
0=>array('file'=>'box_graph_invoices_supplier_permonth.php','enabledbydefaulton'=>'Home'),
Expand Down Expand Up @@ -629,6 +636,26 @@ public function init($options = '')

$this->remove($options);

//ODT template
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_orders/template_supplier_order.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_orders';
$dest=$dirodt.'/template_supplier_order.odt';

file_put_contents("test.txt", var_export($dest, true));

if (file_exists($src) && ! file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
$result=dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}

$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'order_supplier' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order_supplier',".$conf->entity.")",
Expand Down

0 comments on commit 75152cb

Please sign in to comment.