Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
parent
31956d8912
commit
1eab97080c
@ -79,7 +79,7 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--- Finds and returns the document
|
//--- Finds and returns the document
|
||||||
$entity=$conf->entity;
|
$entity = $conf->entity;
|
||||||
|
|
||||||
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
|
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
|
||||||
$accessallowed = $check_access['accessallowed'];
|
$accessallowed = $check_access['accessallowed'];
|
||||||
@ -94,16 +94,16 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$filename = basename($original_file);
|
$filename = basename($original_file);
|
||||||
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
|
$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
|
||||||
|
|
||||||
if (! file_exists($original_file_osencoded))
|
if (!file_exists($original_file_osencoded))
|
||||||
{
|
{
|
||||||
dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING);
|
dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING);
|
||||||
throw new RestException(404, 'File not found');
|
throw new RestException(404, 'File not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_content=file_get_contents($original_file_osencoded);
|
$file_content = file_get_contents($original_file_osencoded);
|
||||||
return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64' );
|
return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,12 +141,12 @@ class Documents extends DolibarrApi
|
|||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if ($langcode && $langs->defaultlang != $langcode)
|
if ($langcode && $langs->defaultlang != $langcode)
|
||||||
{
|
{
|
||||||
$outputlangs=new Translate('', $conf);
|
$outputlangs = new Translate('', $conf);
|
||||||
$outputlangs->setDefaultLang($langcode);
|
$outputlangs->setDefaultLang($langcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--- Finds and returns the document
|
//--- Finds and returns the document
|
||||||
$entity=$conf->entity;
|
$entity = $conf->entity;
|
||||||
|
|
||||||
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write');
|
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write');
|
||||||
$accessallowed = $check_access['accessallowed'];
|
$accessallowed = $check_access['accessallowed'];
|
||||||
@ -165,20 +165,20 @@ class Documents extends DolibarrApi
|
|||||||
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
|
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
|
||||||
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
|
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
|
||||||
|
|
||||||
$templateused='';
|
$templateused = '';
|
||||||
|
|
||||||
if ($modulepart == 'facture' || $modulepart == 'invoice')
|
if ($modulepart == 'facture' || $modulepart == 'invoice')
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
$this->invoice = new Facture($this->db);
|
$this->invoice = new Facture($this->db);
|
||||||
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Invoice not found');
|
throw new RestException(404, 'Invoice not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$templateused = $doctemplate?$doctemplate:$this->invoice->modelpdf;
|
$templateused = $doctemplate ? $doctemplate : $this->invoice->modelpdf;
|
||||||
$result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if( $result <= 0 ) {
|
if ($result <= 0) {
|
||||||
throw new RestException(500, 'Error generating document');
|
throw new RestException(500, 'Error generating document');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,12 +187,12 @@ class Documents extends DolibarrApi
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||||
$this->order = new Commande($this->db);
|
$this->order = new Commande($this->db);
|
||||||
$result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
$result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
$templateused = $doctemplate?$doctemplate:$this->order->modelpdf;
|
$templateused = $doctemplate ? $doctemplate : $this->order->modelpdf;
|
||||||
$result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if( $result <= 0 ) {
|
if ($result <= 0) {
|
||||||
throw new RestException(500, 'Error generating document');
|
throw new RestException(500, 'Error generating document');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,12 +201,12 @@ class Documents extends DolibarrApi
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||||
$this->propal = new Propal($this->db);
|
$this->propal = new Propal($this->db);
|
||||||
$result = $this->propal->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
$result = $this->propal->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
||||||
if( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Proposal not found');
|
throw new RestException(404, 'Proposal not found');
|
||||||
}
|
}
|
||||||
$templateused = $doctemplate?$doctemplate:$this->propal->modelpdf;
|
$templateused = $doctemplate ? $doctemplate : $this->propal->modelpdf;
|
||||||
$result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if( $result <= 0 ) {
|
if ($result <= 0) {
|
||||||
throw new RestException(500, 'Error generating document');
|
throw new RestException(500, 'Error generating document');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,15 +216,15 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$filename = basename($original_file);
|
$filename = basename($original_file);
|
||||||
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
|
$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
|
||||||
|
|
||||||
if (! file_exists($original_file_osencoded))
|
if (!file_exists($original_file_osencoded))
|
||||||
{
|
{
|
||||||
throw new RestException(404, 'File not found');
|
throw new RestException(404, 'File not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_content=file_get_contents($original_file_osencoded);
|
$file_content = file_get_contents($original_file_osencoded);
|
||||||
return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64' );
|
return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,7 +257,7 @@ class Documents extends DolibarrApi
|
|||||||
throw new RestException(400, 'bad value for parameter id or ref');
|
throw new RestException(400, 'bad value for parameter id or ref');
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = (empty($id)?0:$id);
|
$id = (empty($id) ? 0 : $id);
|
||||||
|
|
||||||
if ($modulepart == 'societe' || $modulepart == 'thirdparty')
|
if ($modulepart == 'societe' || $modulepart == 'thirdparty')
|
||||||
{
|
{
|
||||||
@ -268,12 +268,12 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
$result=$object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Thirdparty not found');
|
throw new RestException(404, 'Thirdparty not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id;
|
$upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'adherent' || $modulepart == 'member')
|
elseif ($modulepart == 'adherent' || $modulepart == 'member')
|
||||||
{
|
{
|
||||||
@ -284,12 +284,12 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object = new Adherent($this->db);
|
$object = new Adherent($this->db);
|
||||||
$result=$object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Member not found');
|
throw new RestException(404, 'Member not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member');
|
$upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'propal' || $modulepart == 'proposal')
|
elseif ($modulepart == 'propal' || $modulepart == 'proposal')
|
||||||
{
|
{
|
||||||
@ -300,12 +300,12 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object = new Propal($this->db);
|
$object = new Propal($this->db);
|
||||||
$result=$object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Proposal not found');
|
throw new RestException(404, 'Proposal not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal');
|
$upload_dir = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'commande' || $modulepart == 'order')
|
elseif ($modulepart == 'commande' || $modulepart == 'order')
|
||||||
{
|
{
|
||||||
@ -316,12 +316,12 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object = new Commande($this->db);
|
$object = new Commande($this->db);
|
||||||
$result=$object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Order not found');
|
throw new RestException(404, 'Order not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande');
|
$upload_dir = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande');
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'shipment' || $modulepart == 'expedition')
|
elseif ($modulepart == 'shipment' || $modulepart == 'expedition')
|
||||||
{
|
{
|
||||||
@ -332,12 +332,12 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object = new Expedition($this->db);
|
$object = new Expedition($this->db);
|
||||||
$result=$object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Shipment not found');
|
throw new RestException(404, 'Shipment not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment');
|
$upload_dir = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'facture' || $modulepart == 'invoice')
|
elseif ($modulepart == 'facture' || $modulepart == 'invoice')
|
||||||
{
|
{
|
||||||
@ -348,12 +348,12 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object = new Facture($this->db);
|
$object = new Facture($this->db);
|
||||||
$result=$object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Invoice not found');
|
throw new RestException(404, 'Invoice not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice');
|
$upload_dir = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice');
|
||||||
}
|
}
|
||||||
elseif ($modulepart == 'produit' || $modulepart == 'product')
|
elseif ($modulepart == 'produit' || $modulepart == 'product')
|
||||||
{
|
{
|
||||||
@ -364,8 +364,8 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object = new Product($this->db);
|
$object = new Product($this->db);
|
||||||
$result=$object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Product not found');
|
throw new RestException(404, 'Product not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,8 +380,8 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object = new ActionComm($this->db);
|
$object = new ActionComm($this->db);
|
||||||
$result=$object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
if ( ! $result ) {
|
if (!$result) {
|
||||||
throw new RestException(404, 'Event not found');
|
throw new RestException(404, 'Event not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,9 +392,9 @@ class Documents extends DolibarrApi
|
|||||||
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
|
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1);
|
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||||
if (empty($filearray)) {
|
if (empty($filearray)) {
|
||||||
throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.');
|
throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->Ref) ? ' or Ref '.$object->ref : '').' does not return any document.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $filearray;
|
return $filearray;
|
||||||
@ -447,7 +447,7 @@ class Documents extends DolibarrApi
|
|||||||
var_dump($filecontent);
|
var_dump($filecontent);
|
||||||
exit;*/
|
exit;*/
|
||||||
|
|
||||||
if(empty($modulepart))
|
if (empty($modulepart))
|
||||||
{
|
{
|
||||||
throw new RestException(400, 'Modulepart not provided.');
|
throw new RestException(400, 'Modulepart not provided.');
|
||||||
}
|
}
|
||||||
@ -467,11 +467,11 @@ class Documents extends DolibarrApi
|
|||||||
$entity = DolibarrApiAccess::$user->entity;
|
$entity = DolibarrApiAccess::$user->entity;
|
||||||
if ($ref)
|
if ($ref)
|
||||||
{
|
{
|
||||||
$tmpreldir='';
|
$tmpreldir = '';
|
||||||
|
|
||||||
if ($modulepart == 'facture' || $modulepart == 'invoice')
|
if ($modulepart == 'facture' || $modulepart == 'invoice')
|
||||||
{
|
{
|
||||||
$modulepart='facture';
|
$modulepart = 'facture';
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
$object = new Facture($this->db);
|
$object = new Facture($this->db);
|
||||||
@ -491,11 +491,11 @@ class Documents extends DolibarrApi
|
|||||||
$task_result = $object->fetch('', $ref);
|
$task_result = $object->fetch('', $ref);
|
||||||
|
|
||||||
// Fetching the tasks project is required because its out_dir might be a sub-directory of the project
|
// Fetching the tasks project is required because its out_dir might be a sub-directory of the project
|
||||||
if($task_result > 0)
|
if ($task_result > 0)
|
||||||
{
|
{
|
||||||
$project_result = $object->fetch_projet();
|
$project_result = $object->fetch_projet();
|
||||||
|
|
||||||
if($project_result >= 0)
|
if ($project_result >= 0)
|
||||||
{
|
{
|
||||||
$tmpreldir = dol_sanitizeFileName($object->project->ref).'/';
|
$tmpreldir = dol_sanitizeFileName($object->project->ref).'/';
|
||||||
}
|
}
|
||||||
@ -516,11 +516,11 @@ class Documents extends DolibarrApi
|
|||||||
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
|
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_object($object))
|
if (is_object($object))
|
||||||
{
|
{
|
||||||
$result = $object->fetch('', $ref);
|
$result = $object->fetch('', $ref);
|
||||||
|
|
||||||
if($result == 0)
|
if ($result == 0)
|
||||||
{
|
{
|
||||||
throw new RestException(404, "Object with ref '".$ref."' was not found.");
|
throw new RestException(404, "Object with ref '".$ref."' was not found.");
|
||||||
}
|
}
|
||||||
@ -530,7 +530,7 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ($object->id > 0))
|
if (!($object->id > 0))
|
||||||
{
|
{
|
||||||
throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found.");
|
throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found.");
|
||||||
}
|
}
|
||||||
@ -547,7 +547,7 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($modulepart == 'invoice') $modulepart ='facture';
|
if ($modulepart == 'invoice') $modulepart = 'facture';
|
||||||
|
|
||||||
$relativefile = $subdir;
|
$relativefile = $subdir;
|
||||||
|
|
||||||
@ -568,8 +568,8 @@ class Documents extends DolibarrApi
|
|||||||
throw new RestException(500, 'Error while trying to create directory.');
|
throw new RestException(500, 'Error while trying to create directory.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$destfile = $upload_dir . '/' . $original_file;
|
$destfile = $upload_dir.'/'.$original_file;
|
||||||
$destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file;
|
$destfiletmp = DOL_DATA_ROOT.'/admin/temp/'.$original_file;
|
||||||
dol_delete_file($destfiletmp);
|
dol_delete_file($destfiletmp);
|
||||||
//var_dump($original_file);exit;
|
//var_dump($original_file);exit;
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ class Documents extends DolibarrApi
|
|||||||
throw new RestException(401, 'Directory not exists : '.dirname($destfile));
|
throw new RestException(401, 'Directory not exists : '.dirname($destfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $overwriteifexists && dol_is_file($destfile))
|
if (!$overwriteifexists && dol_is_file($destfile))
|
||||||
{
|
{
|
||||||
throw new RestException(500, "File with name '".$original_file."' already exists.");
|
throw new RestException(500, "File with name '".$original_file."' already exists.");
|
||||||
}
|
}
|
||||||
@ -595,7 +595,7 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1);
|
$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1);
|
||||||
if (! $result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
throw new RestException(500, "Failed to move file into '".$destfile."'");
|
throw new RestException(500, "Failed to move file into '".$destfile."'");
|
||||||
}
|
}
|
||||||
@ -629,7 +629,7 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--- Finds and returns the document
|
//--- Finds and returns the document
|
||||||
$entity=$conf->entity;
|
$entity = $conf->entity;
|
||||||
|
|
||||||
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
|
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
|
||||||
$accessallowed = $check_access['accessallowed'];
|
$accessallowed = $check_access['accessallowed'];
|
||||||
@ -644,9 +644,9 @@ class Documents extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$filename = basename($original_file);
|
$filename = basename($original_file);
|
||||||
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
|
$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
|
||||||
|
|
||||||
if (! file_exists($original_file_osencoded))
|
if (!file_exists($original_file_osencoded))
|
||||||
{
|
{
|
||||||
dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING);
|
dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING);
|
||||||
throw new RestException(404, 'File not found');
|
throw new RestException(404, 'File not found');
|
||||||
|
|||||||
@ -75,11 +75,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
|
|||||||
//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
|
//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
|
||||||
//$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
|
//$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
|
||||||
|
|
||||||
$permissionnote=$user->rights->bom->write; // Used by the include of actions_setnotes.inc.php
|
$permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php
|
||||||
$permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php
|
$permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php
|
||||||
$permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
$permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||||
$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||||
$upload_dir = $conf->bom->multidir_output[isset($object->entity)?$object->entity:1];
|
$upload_dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -521,29 +521,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
* Lines
|
* Lines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! empty($object->table_element_line))
|
if (!empty($object->table_element_line))
|
||||||
{
|
{
|
||||||
// Show object lines
|
// Show object lines
|
||||||
$result = $object->getLinesArray();
|
$result = $object->getLinesArray();
|
||||||
|
|
||||||
print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#addline' : '#line_' . GETPOST('lineid', 'int')) . '" method="POST">
|
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
|
||||||
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">
|
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'">
|
||||||
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '">
|
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
|
||||||
<input type="hidden" name="mode" value="">
|
<input type="hidden" name="mode" value="">
|
||||||
<input type="hidden" name="id" value="' . $object->id . '">
|
<input type="hidden" name="id" value="' . $object->id.'">
|
||||||
';
|
';
|
||||||
|
|
||||||
if (! empty($conf->use_javascript_ajax) && $object->status == 0) {
|
if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
|
||||||
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
||||||
{
|
{
|
||||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($object->lines))
|
if (!empty($object->lines))
|
||||||
{
|
{
|
||||||
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
|
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
|
||||||
}
|
}
|
||||||
@ -561,7 +561,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
||||||
{
|
{
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
@ -613,11 +613,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
{
|
{
|
||||||
if (is_array($object->lines) && count($object->lines) > 0)
|
if (is_array($object->lines) && count($object->lines) > 0)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=validate">' . $langs->trans("Validate") . '</a>';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<a class="butActionRefused" href="" title="'.$langs->trans("AddAtLeastOneLineFirst").'">' . $langs->trans("Validate") . '</a>';
|
print '<a class="butActionRefused" href="" title="'.$langs->trans("AddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
global $conf, $langs, $mysoc;
|
global $conf, $langs, $mysoc;
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("main","companies"));
|
$langs->loadLangs(array("main", "companies"));
|
||||||
|
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->name = "ODT templates";
|
$this->name = "ODT templates";
|
||||||
@ -79,11 +79,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
$this->type = 'odt';
|
$this->type = 'odt';
|
||||||
$this->page_largeur = 0;
|
$this->page_largeur = 0;
|
||||||
$this->page_hauteur = 0;
|
$this->page_hauteur = 0;
|
||||||
$this->format = array($this->page_largeur,$this->page_hauteur);
|
$this->format = array($this->page_largeur, $this->page_hauteur);
|
||||||
$this->marge_gauche=0;
|
$this->marge_gauche = 0;
|
||||||
$this->marge_droite=0;
|
$this->marge_droite = 0;
|
||||||
$this->marge_haute=0;
|
$this->marge_haute = 0;
|
||||||
$this->marge_basse=0;
|
$this->marge_basse = 0;
|
||||||
|
|
||||||
$this->option_logo = 1; // Affiche logo
|
$this->option_logo = 1; // Affiche logo
|
||||||
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
|
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
|
||||||
@ -97,8 +97,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
|
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
|
||||||
|
|
||||||
// Recupere emetteur
|
// Recupere emetteur
|
||||||
$this->emetteur=$mysoc;
|
$this->emetteur = $mysoc;
|
||||||
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
|
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -110,83 +110,83 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
*/
|
*/
|
||||||
public function info($langs)
|
public function info($langs)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("errors","companies"));
|
$langs->loadLangs(array("errors", "companies"));
|
||||||
|
|
||||||
$form = new Form($this->db);
|
$form = new Form($this->db);
|
||||||
|
|
||||||
$texte = $this->description.".<br>\n";
|
$texte = $this->description.".<br>\n";
|
||||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
|
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
|
||||||
$texte.= '<input type="hidden" name="param1" value="MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH">';
|
$texte .= '<input type="hidden" name="param1" value="MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH">';
|
||||||
$texte.= '<table class="nobordernopadding" width="100%">';
|
$texte .= '<table class="nobordernopadding" width="100%">';
|
||||||
|
|
||||||
// List of directories area
|
// List of directories area
|
||||||
$texte.= '<tr><td>';
|
$texte .= '<tr><td>';
|
||||||
$texttitle=$langs->trans("ListOfDirectories");
|
$texttitle = $langs->trans("ListOfDirectories");
|
||||||
$listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)));
|
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)));
|
||||||
$listoffiles=array();
|
$listoffiles = array();
|
||||||
foreach($listofdir as $key=>$tmpdir)
|
foreach ($listofdir as $key=>$tmpdir)
|
||||||
{
|
{
|
||||||
$tmpdir=trim($tmpdir);
|
$tmpdir = trim($tmpdir);
|
||||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||||
if (! $tmpdir) {
|
if (!$tmpdir) {
|
||||||
unset($listofdir[$key]); continue;
|
unset($listofdir[$key]); continue;
|
||||||
}
|
}
|
||||||
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
|
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
|
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
|
||||||
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
|
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
|
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
|
||||||
// Add list of substitution keys
|
// Add list of substitution keys
|
||||||
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
|
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
|
||||||
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
|
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
|
||||||
|
|
||||||
$texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
|
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
|
||||||
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
|
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
|
||||||
$texte.= '<textarea class="flat" cols="60" name="value1">';
|
$texte .= '<textarea class="flat" cols="60" name="value1">';
|
||||||
$texte.=$conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH;
|
$texte .= $conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH;
|
||||||
$texte.= '</textarea>';
|
$texte .= '</textarea>';
|
||||||
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
|
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
|
||||||
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
|
$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
|
||||||
$texte.= '<br></div></div>';
|
$texte .= '<br></div></div>';
|
||||||
|
|
||||||
// Scan directories
|
// Scan directories
|
||||||
$nbofiles=count($listoffiles);
|
$nbofiles = count($listoffiles);
|
||||||
if (! empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH))
|
if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH))
|
||||||
{
|
{
|
||||||
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
|
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
|
||||||
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
|
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
|
||||||
$texte.=count($listoffiles);
|
$texte .= count($listoffiles);
|
||||||
//$texte.=$nbofiles?'</a>':'';
|
//$texte.=$nbofiles?'</a>':'';
|
||||||
$texte.='</b>';
|
$texte .= '</b>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($nbofiles)
|
if ($nbofiles)
|
||||||
{
|
{
|
||||||
$texte.='<div id="div_'.get_class($this).'" class="hidden">';
|
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
|
||||||
foreach($listoffiles as $file)
|
foreach ($listoffiles as $file)
|
||||||
{
|
{
|
||||||
$texte.=$file['name'].'<br>';
|
$texte .= $file['name'].'<br>';
|
||||||
}
|
}
|
||||||
$texte.='<div id="div_'.get_class($this).'">';
|
$texte .= '<div id="div_'.get_class($this).'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
$texte.= '</td>';
|
$texte .= '</td>';
|
||||||
|
|
||||||
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
|
$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
|
||||||
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
|
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
|
||||||
$texte.= '</td>';
|
$texte .= '</td>';
|
||||||
$texte.= '</tr>';
|
$texte .= '</tr>';
|
||||||
|
|
||||||
$texte.= '</table>';
|
$texte .= '</table>';
|
||||||
$texte.= '</form>';
|
$texte .= '</form>';
|
||||||
|
|
||||||
return $texte;
|
return $texte;
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $user,$langs,$conf,$mysoc,$hookmanager;
|
global $user, $langs, $conf, $mysoc, $hookmanager;
|
||||||
|
|
||||||
if (empty($srctemplatepath))
|
if (empty($srctemplatepath))
|
||||||
{
|
{
|
||||||
@ -215,28 +215,28 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add odtgeneration hook
|
// Add odtgeneration hook
|
||||||
if (! is_object($hookmanager))
|
if (!is_object($hookmanager))
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
$hookmanager=new HookManager($this->db);
|
$hookmanager = new HookManager($this->db);
|
||||||
}
|
}
|
||||||
$hookmanager->initHooks(array('odtgeneration'));
|
$hookmanager->initHooks(array('odtgeneration'));
|
||||||
global $action;
|
global $action;
|
||||||
|
|
||||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
if (!is_object($outputlangs)) $outputlangs = $langs;
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
$sav_charset_output = $outputlangs->charset_output;
|
||||||
$outputlangs->charset_output='UTF-8';
|
$outputlangs->charset_output = 'UTF-8';
|
||||||
|
|
||||||
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
|
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
|
||||||
|
|
||||||
if ($conf->commande->dir_output)
|
if ($conf->commande->dir_output)
|
||||||
{
|
{
|
||||||
// If $object is id instead of object
|
// If $object is id instead of object
|
||||||
if (! is_object($object))
|
if (!is_object($object))
|
||||||
{
|
{
|
||||||
$id = $object;
|
$id = $object;
|
||||||
$object = new Commande($this->db);
|
$object = new Commande($this->db);
|
||||||
$result=$object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
dol_print_error($this->db, $object->error);
|
dol_print_error($this->db, $object->error);
|
||||||
@ -244,16 +244,16 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dir = $conf->commande->multidir_output[isset($object->entity)?$object->entity:1];
|
$dir = $conf->commande->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||||
$objectref = dol_sanitizeFileName($object->ref);
|
$objectref = dol_sanitizeFileName($object->ref);
|
||||||
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
|
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
|
||||||
$file = $dir . "/" . $objectref . ".odt";
|
$file = $dir."/".$objectref.".odt";
|
||||||
|
|
||||||
if (! file_exists($dir))
|
if (!file_exists($dir))
|
||||||
{
|
{
|
||||||
if (dol_mkdir($dir) < 0)
|
if (dol_mkdir($dir) < 0)
|
||||||
{
|
{
|
||||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,25 +261,25 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
if (file_exists($dir))
|
if (file_exists($dir))
|
||||||
{
|
{
|
||||||
//print "srctemplatepath=".$srctemplatepath; // Src filename
|
//print "srctemplatepath=".$srctemplatepath; // Src filename
|
||||||
$newfile=basename($srctemplatepath);
|
$newfile = basename($srctemplatepath);
|
||||||
$newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile);
|
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
|
||||||
$newfiletmp=preg_replace('/template_/i', '', $newfiletmp);
|
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
|
||||||
$newfiletmp=preg_replace('/modele_/i', '', $newfiletmp);
|
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
|
||||||
$newfiletmp=$objectref.'_'.$newfiletmp;
|
$newfiletmp = $objectref.'_'.$newfiletmp;
|
||||||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||||
// Get extension (ods or odt)
|
// Get extension (ods or odt)
|
||||||
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
|
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||||
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
|
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
|
||||||
{
|
{
|
||||||
$format=$conf->global->MAIN_DOC_USE_TIMING;
|
$format = $conf->global->MAIN_DOC_USE_TIMING;
|
||||||
if ($format == '1') $format='%Y%m%d%H%M%S';
|
if ($format == '1') $format = '%Y%m%d%H%M%S';
|
||||||
$filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
|
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$filename=$newfiletmp.'.'.$newfileformat;
|
$filename = $newfiletmp.'.'.$newfileformat;
|
||||||
}
|
}
|
||||||
$file=$dir.'/'.$filename;
|
$file = $dir.'/'.$filename;
|
||||||
//print "newdir=".$dir;
|
//print "newdir=".$dir;
|
||||||
//print "newfile=".$newfile;
|
//print "newfile=".$newfile;
|
||||||
//print "file=".$file;
|
//print "file=".$file;
|
||||||
@ -289,20 +289,20 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
|
|
||||||
|
|
||||||
// If CUSTOMER contact defined on order, we use it
|
// If CUSTOMER contact defined on order, we use it
|
||||||
$usecontact=false;
|
$usecontact = false;
|
||||||
$arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
|
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
|
||||||
if (count($arrayidcontact) > 0)
|
if (count($arrayidcontact) > 0)
|
||||||
{
|
{
|
||||||
$usecontact=true;
|
$usecontact = true;
|
||||||
$result=$object->fetch_contact($arrayidcontact[0]);
|
$result = $object->fetch_contact($arrayidcontact[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recipient name
|
// Recipient name
|
||||||
$contactobject=null;
|
$contactobject = null;
|
||||||
if (! empty($usecontact))
|
if (!empty($usecontact))
|
||||||
{
|
{
|
||||||
// On peut utiliser le nom de la societe du contact
|
// On peut utiliser le nom de la societe du contact
|
||||||
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
|
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
|
||||||
else {
|
else {
|
||||||
$socobject = $object->thirdparty;
|
$socobject = $object->thirdparty;
|
||||||
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
|
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
|
||||||
@ -311,11 +311,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$socobject=$object->thirdparty;
|
$socobject = $object->thirdparty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make substitution
|
// Make substitution
|
||||||
$substitutionarray=array(
|
$substitutionarray = array(
|
||||||
'__FROM_NAME__' => $this->emetteur->name,
|
'__FROM_NAME__' => $this->emetteur->name,
|
||||||
'__FROM_EMAIL__' => $this->emetteur->email,
|
'__FROM_EMAIL__' => $this->emetteur->email,
|
||||||
'__TOTAL_TTC__' => $object->total_ttc,
|
'__TOTAL_TTC__' => $object->total_ttc,
|
||||||
@ -324,15 +324,15 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
);
|
);
|
||||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
complete_substitutions_array($substitutionarray, $langs, $object);
|
||||||
// Call the ODTSubstitution hook
|
// Call the ODTSubstitution hook
|
||||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
|
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
|
||||||
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
// Line of free text
|
// Line of free text
|
||||||
$newfreetext='';
|
$newfreetext = '';
|
||||||
$paramfreetext='ORDER_FREE_TEXT';
|
$paramfreetext = 'ORDER_FREE_TEXT';
|
||||||
if (! empty($conf->global->$paramfreetext))
|
if (!empty($conf->global->$paramfreetext))
|
||||||
{
|
{
|
||||||
$newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray);
|
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open and load template
|
// Open and load template
|
||||||
@ -348,9 +348,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error = $e->getMessage();
|
||||||
dol_syslog($e->getMessage(), LOG_INFO);
|
dol_syslog($e->getMessage(), LOG_INFO);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -365,31 +365,31 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
try {
|
try {
|
||||||
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
|
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
|
||||||
}
|
}
|
||||||
catch(OdfException $e)
|
catch (OdfException $e)
|
||||||
{
|
{
|
||||||
dol_syslog($e->getMessage(), LOG_INFO);
|
dol_syslog($e->getMessage(), LOG_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define substitution array
|
// Define substitution array
|
||||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||||
$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
|
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
|
||||||
$array_objet=$this->get_substitutionarray_object($object, $outputlangs);
|
$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
|
||||||
$array_user=$this->get_substitutionarray_user($user, $outputlangs);
|
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
|
||||||
$array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs);
|
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
|
||||||
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs);
|
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
|
||||||
$array_other=$this->get_substitutionarray_other($outputlangs);
|
$array_other = $this->get_substitutionarray_other($outputlangs);
|
||||||
// retrieve contact information for use in object as contact_xxx tags
|
// retrieve contact information for use in object as contact_xxx tags
|
||||||
$array_thirdparty_contact = array();
|
$array_thirdparty_contact = array();
|
||||||
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
|
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
|
||||||
|
|
||||||
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
|
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||||
|
|
||||||
// Call the ODTSubstitution hook
|
// Call the ODTSubstitution hook
|
||||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
|
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||||
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
foreach($tmparray as $key=>$value)
|
foreach ($tmparray as $key=>$value)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (preg_match('/logo$/', $key)) // Image
|
if (preg_match('/logo$/', $key)) // Image
|
||||||
@ -402,7 +402,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(OdfException $e)
|
catch (OdfException $e)
|
||||||
{
|
{
|
||||||
dol_syslog($e->getMessage(), LOG_INFO);
|
dol_syslog($e->getMessage(), LOG_INFO);
|
||||||
}
|
}
|
||||||
@ -414,7 +414,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
try {
|
try {
|
||||||
$listlines = $odfHandler->setSegment('lines');
|
$listlines = $odfHandler->setSegment('lines');
|
||||||
}
|
}
|
||||||
catch(OdfException $e)
|
catch (OdfException $e)
|
||||||
{
|
{
|
||||||
// We may arrive here if tags for lines not present into template
|
// We may arrive here if tags for lines not present into template
|
||||||
$foundtagforlines = 0;
|
$foundtagforlines = 0;
|
||||||
@ -424,22 +424,22 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
{
|
{
|
||||||
foreach ($object->lines as $line)
|
foreach ($object->lines as $line)
|
||||||
{
|
{
|
||||||
$tmparray=$this->get_substitutionarray_lines($line, $outputlangs);
|
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
||||||
// Call the ODTSubstitutionLine hook
|
// Call the ODTSubstitutionLine hook
|
||||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
|
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
|
||||||
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
foreach($tmparray as $key => $val)
|
foreach ($tmparray as $key => $val)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||||
}
|
}
|
||||||
catch(OdfException $e)
|
catch (OdfException $e)
|
||||||
{
|
{
|
||||||
dol_syslog($e->getMessage(), LOG_INFO);
|
dol_syslog($e->getMessage(), LOG_INFO);
|
||||||
}
|
}
|
||||||
catch(SegmentException $e)
|
catch (SegmentException $e)
|
||||||
{
|
{
|
||||||
dol_syslog($e->getMessage(), LOG_INFO);
|
dol_syslog($e->getMessage(), LOG_INFO);
|
||||||
}
|
}
|
||||||
@ -449,21 +449,21 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
$odfHandler->mergeSegment($listlines);
|
$odfHandler->mergeSegment($listlines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(OdfException $e)
|
catch (OdfException $e)
|
||||||
{
|
{
|
||||||
$this->error=$e->getMessage();
|
$this->error = $e->getMessage();
|
||||||
dol_syslog($this->error, LOG_WARNING);
|
dol_syslog($this->error, LOG_WARNING);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace labels translated
|
// Replace labels translated
|
||||||
$tmparray=$outputlangs->get_translations_for_substitutions();
|
$tmparray = $outputlangs->get_translations_for_substitutions();
|
||||||
foreach($tmparray as $key=>$value)
|
foreach ($tmparray as $key=>$value)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||||
}
|
}
|
||||||
catch(OdfException $e)
|
catch (OdfException $e)
|
||||||
{
|
{
|
||||||
dol_syslog($e->getMessage(), LOG_INFO);
|
dol_syslog($e->getMessage(), LOG_INFO);
|
||||||
}
|
}
|
||||||
@ -471,15 +471,15 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
|
|
||||||
// Call the beforeODTSave hook
|
// Call the beforeODTSave hook
|
||||||
|
|
||||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
|
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||||
$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
|
||||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
try {
|
try {
|
||||||
$odfHandler->exportAsAttachedPDF($file);
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
}catch (Exception $e){
|
} catch (Exception $e) {
|
||||||
$this->error=$e->getMessage();
|
$this->error = $e->getMessage();
|
||||||
dol_syslog($e->getMessage(), LOG_INFO);
|
dol_syslog($e->getMessage(), LOG_INFO);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -488,19 +488,19 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
try {
|
try {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->error=$e->getMessage();
|
$this->error = $e->getMessage();
|
||||||
dol_syslog($e->getMessage(), LOG_INFO);
|
dol_syslog($e->getMessage(), LOG_INFO);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
|
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
|
||||||
$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
$odfHandler=null; // Destroy object
|
$odfHandler = null; // Destroy object
|
||||||
|
|
||||||
$this->result = array('fullpath'=>$file);
|
$this->result = array('fullpath'=>$file);
|
||||||
|
|
||||||
@ -508,7 +508,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the inc
|
|||||||
$permissiontodelete = $user->rights->mymodule->myobject->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
$permissiontodelete = $user->rights->mymodule->myobject->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||||
$permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php
|
$permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php
|
||||||
$permissiondellink = $user->rights->mymodule->myobject->write; // Used by the include of actions_dellink.inc.php
|
$permissiondellink = $user->rights->mymodule->myobject->write; // Used by the include of actions_dellink.inc.php
|
||||||
$upload_dir = $conf->mymodule->multidir_output[isset($object->entity)?$object->entity:1];
|
$upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -392,29 +392,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
* Lines
|
* Lines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! empty($object->table_element_line))
|
if (!empty($object->table_element_line))
|
||||||
{
|
{
|
||||||
// Show object lines
|
// Show object lines
|
||||||
$result = $object->getLinesArray();
|
$result = $object->getLinesArray();
|
||||||
|
|
||||||
print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#addline' : '#line_' . GETPOST('lineid', 'int')) . '" method="POST">
|
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
|
||||||
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">
|
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'">
|
||||||
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '">
|
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
|
||||||
<input type="hidden" name="mode" value="">
|
<input type="hidden" name="mode" value="">
|
||||||
<input type="hidden" name="id" value="' . $object->id . '">
|
<input type="hidden" name="id" value="' . $object->id.'">
|
||||||
';
|
';
|
||||||
|
|
||||||
if (! empty($conf->use_javascript_ajax) && $object->status == 0) {
|
if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
|
||||||
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
||||||
{
|
{
|
||||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($object->lines))
|
if (!empty($object->lines))
|
||||||
{
|
{
|
||||||
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
|
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
||||||
{
|
{
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
@ -446,21 +446,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
|
|
||||||
if ($action != 'presend' && $action != 'editline') {
|
if ($action != 'presend' && $action != 'editline') {
|
||||||
print '<div class="tabsAction">'."\n";
|
print '<div class="tabsAction">'."\n";
|
||||||
$parameters=array();
|
$parameters = array();
|
||||||
$reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
// Send
|
// Send
|
||||||
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
|
||||||
|
|
||||||
// Back to draft
|
// Back to draft
|
||||||
if ($object->status == $object::STATUS_VALIDATED)
|
if ($object->status == $object::STATUS_VALIDATED)
|
||||||
{
|
{
|
||||||
if ($permissiontoadd)
|
if ($permissiontoadd)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=setdraft">' . $langs->trans("SetToDraft") . '</a>';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=setdraft">'.$langs->trans("SetToDraft").'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +493,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
// Clone
|
// Clone
|
||||||
if ($permissiontoadd)
|
if ($permissiontoadd)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&socid=' . $object->socid . '&action=clone&object=myobject">' . $langs->trans("ToClone") . '</a>'."\n";
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=myobject">'.$langs->trans("ToClone").'</a>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -109,7 +109,7 @@ $permissionnote = $user->rights->mrp->write; // Used by the include of actions_s
|
|||||||
$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php
|
$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php
|
||||||
$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||||
$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||||
$upload_dir = $conf->mrp->multidir_output[isset($object->entity)?$object->entity:1];
|
$upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -97,7 +97,7 @@ $permissionnote = $user->rights->mrp->write; // Used by the include of actions_s
|
|||||||
$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php
|
$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php
|
||||||
$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||||
$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||||
$upload_dir = $conf->mrp->multidir_output[isset($object->entity)?$object->entity:1];
|
$upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user