Merge pull request #8751 from wdammak/patch-7
Add models pdf to warehouse module
This commit is contained in:
commit
9e807c1c01
@ -60,7 +60,7 @@ class modStock extends DolibarrModules
|
|||||||
$this->picto='stock';
|
$this->picto='stock';
|
||||||
|
|
||||||
// Data directories to create when module is enabled
|
// Data directories to create when module is enabled
|
||||||
$this->dirs = array();
|
$this->dirs = array("/stock/temp");
|
||||||
|
|
||||||
$this->config_page_url = array("stock.php");
|
$this->config_page_url = array("stock.php");
|
||||||
|
|
||||||
@ -70,9 +70,38 @@ class modStock extends DolibarrModules
|
|||||||
$this->langfiles = array("stocks");
|
$this->langfiles = array("stocks");
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
$this->const = array(
|
$this->const = array();
|
||||||
0=>array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1)
|
$r=0;
|
||||||
);
|
|
||||||
|
$this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1);
|
||||||
|
|
||||||
|
$r++;
|
||||||
|
$this->const[$r][0] = "STOCK_ADDON_PDF";
|
||||||
|
$this->const[$r][1] = "chaine";
|
||||||
|
$this->const[$r][2] = "Standard";
|
||||||
|
$this->const[$r][3] = 'Name of PDF model of stock';
|
||||||
|
$this->const[$r][4] = 0;
|
||||||
|
|
||||||
|
$r++;
|
||||||
|
$this->const[$r][0] = "MOUVEMENT_ADDON_PDF";
|
||||||
|
$this->const[$r][1] = "chaine";
|
||||||
|
$this->const[$r][2] = "StdMouvement";
|
||||||
|
$this->const[$r][3] = 'Name of PDF model of stock mouvement';
|
||||||
|
$this->const[$r][4] = 0;
|
||||||
|
|
||||||
|
$r++;
|
||||||
|
$this->const[$r][0] = "STOCK_ADDON_PDF_ODT_PATH";
|
||||||
|
$this->const[$r][1] = "chaine";
|
||||||
|
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks";
|
||||||
|
$this->const[$r][3] = "";
|
||||||
|
$this->const[$r][4] = 0;
|
||||||
|
|
||||||
|
$r++;
|
||||||
|
$this->const[$r][0] = "MOUVEMENT_ADDON_PDF_ODT_PATH";
|
||||||
|
$this->const[$r][1] = "chaine";
|
||||||
|
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks/mouvements";
|
||||||
|
$this->const[$r][3] = "";
|
||||||
|
$this->const[$r][4] = 0;
|
||||||
|
|
||||||
// Boxes
|
// Boxes
|
||||||
$this->boxes = array();
|
$this->boxes = array();
|
||||||
@ -266,4 +295,50 @@ class modStock extends DolibarrModules
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when module is enabled.
|
||||||
|
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||||
|
* It also creates data directories
|
||||||
|
*
|
||||||
|
* @param string $options Options when enabling module ('', 'noboxes')
|
||||||
|
* @return int 1 if OK, 0 if KO
|
||||||
|
*/
|
||||||
|
function init($options='')
|
||||||
|
{
|
||||||
|
global $conf,$langs;
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
$this->remove($options);
|
||||||
|
|
||||||
|
//ODT template
|
||||||
|
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt';
|
||||||
|
$dirodt=DOL_DATA_ROOT.'/doctemplates/stock';
|
||||||
|
$dest=$dirodt.'/template_stock.odt';
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
$sql = array(
|
||||||
|
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".$conf->entity,
|
||||||
|
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".$conf->entity.")",
|
||||||
|
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".$conf->entity,
|
||||||
|
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")",
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->_init($sql,$options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user