Merge remote-tracking branch 'Upstream/develop' into develop-64
Conflicts: htdocs/install/mysql/migration/3.8.0-3.9.0.sql
This commit is contained in:
commit
5780d33f9b
@ -1053,49 +1053,6 @@ if (empty($reshook))
|
||||
exit();
|
||||
}
|
||||
|
||||
// Generation doc (depuis lien ou depuis cartouche doc)
|
||||
else if ($action == 'builddoc' && $user->rights->propal->creer) {
|
||||
if (GETPOST('model')) {
|
||||
$object->setDocModel($user, GETPOST('model'));
|
||||
}
|
||||
if (GETPOST('fk_bank')) { // this field may come from an external module
|
||||
$object->fk_bank = GETPOST('fk_bank');
|
||||
} else {
|
||||
$object->fk_bank = $object->fk_account;
|
||||
}
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
// Remove file in doc form
|
||||
else if ($action == 'remove_file' && $user->rights->propal->creer) {
|
||||
if ($object->id > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
|
||||
$langs->load("other");
|
||||
$upload_dir = $conf->propal->dir_output;
|
||||
$file = $upload_dir . '/' . GETPOST('file');
|
||||
$ret = dol_delete_file($file, 0, 0, 0, $object);
|
||||
if ($ret)
|
||||
setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
|
||||
else
|
||||
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Set project
|
||||
else if ($action == 'classin' && $user->rights->propal->creer) {
|
||||
$object->setProject($_POST['projectid']);
|
||||
@ -1211,6 +1168,12 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->propal->dir_output;
|
||||
$permissioncreate=$user->rights->propal->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
108
htdocs/core/actions_builddoc.inc.php
Normal file
108
htdocs/core/actions_builddoc.inc.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/actions_builddoc.inc.php
|
||||
* \brief Code for actions on building or deleting documents
|
||||
*/
|
||||
|
||||
|
||||
// $action must be defined
|
||||
// $id must be defined
|
||||
// $object must be defined and must have a method generateDocument.
|
||||
// $permissioncreate must be defined
|
||||
// $upload_dir must be defined (example $conf->projet->dir_output . "/";)
|
||||
// $hidedetails, $hidedesc and $hideref may have been set or not.
|
||||
|
||||
|
||||
// Build doc
|
||||
if ($action == 'builddoc' && $permissioncreate)
|
||||
{
|
||||
if (is_numeric(GETPOST('model')))
|
||||
{
|
||||
$error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reload to get all modified line records and be ready for hooks
|
||||
$ret = $object->fetch($id);
|
||||
$ret = $object->fetch_thirdparty();
|
||||
/*if (empty($object->id) || ! $object->id > 0)
|
||||
{
|
||||
dol_print_error('Object must have been loaded by a fetch');
|
||||
exit;
|
||||
}*/
|
||||
|
||||
// Save last template used to generate document
|
||||
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||
|
||||
// Special case for invoices
|
||||
if (property_exists($object, 'fk_bank'))
|
||||
{
|
||||
if (GETPOST('fk_bank')) { // this field may come from an external module
|
||||
$object->fk_bank = GETPOST('fk_bank');
|
||||
} else {
|
||||
$object->fk_bank = $object->fk_account;
|
||||
}
|
||||
}
|
||||
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->client->default_lang)) $newlang=$object->client->default_lang; // for proposal, order, invoice, ...
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang=$object->default_lang; // for thirdparty
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
// To be sure vars is defined
|
||||
if (empty($hidedetails)) $hidedetails=0;
|
||||
if (empty($hidedesc)) $hidedesc=0;
|
||||
if (empty($hideref)) $hideref=0;
|
||||
|
||||
$result= $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result <= 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete file in doc form
|
||||
if ($action == 'remove_file' && $permissioncreate)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
if (empty($object->id) || ! $object->id > 0)
|
||||
{
|
||||
// Reload to get all modified line records and be ready for hooks
|
||||
$ret = $object->fetch($id);
|
||||
$ret = $object->fetch_thirdparty();
|
||||
}
|
||||
|
||||
$langs->load("other");
|
||||
$filetodelete=GETPOST('file','alpha');
|
||||
$file = $upload_dir . '/' . $filetodelete;
|
||||
$ret=dol_delete_file($file,0,0,0,$object);
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", $filetodelete));
|
||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", $filetodelete), 'errors');
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
// $action must be defined
|
||||
// $object must be defined
|
||||
// $permissiondellink must be defined
|
||||
// $uploaddir (example $conf->projet->dir_output . "/";)
|
||||
|
||||
$dellinkid = GETPOST('dellinkid','int');
|
||||
|
||||
@ -34,3 +35,5 @@ if ($action == 'dellink' && ! empty($permissiondellink) && ! GETPOST('cancel') &
|
||||
$result=$object->deleteObjectLinked(0, '', 0, '', $dellinkid);
|
||||
if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3432,7 +3432,6 @@ abstract class CommonObject
|
||||
require_once $file;
|
||||
|
||||
$obj = new $classname($this->db);
|
||||
//$obj->message = $message;
|
||||
|
||||
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
|
||||
if ($obj->type == 'odt' && empty($srctemplatepath))
|
||||
|
||||
@ -71,7 +71,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
|
||||
* @param string $modele Force le modele a utiliser ('' to not force)
|
||||
* @param Translate $outputlangs Object lang a utiliser pour traduction
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* TODO
|
||||
* TODO Use commonDocGenerator
|
||||
*/
|
||||
function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
|
||||
{
|
||||
@ -103,7 +103,6 @@ function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
|
||||
require_once $dir.$file;
|
||||
|
||||
$obj = new $classname($db);
|
||||
$obj->message = $message;
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
|
||||
@ -155,8 +155,8 @@ abstract class ModeleNumRefFactures
|
||||
* @param int $hidedesc Hide description
|
||||
* @param int $hideref Hide ref
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @deprecated Use the new function generateDocument of Facture class
|
||||
* @see Facture::generateDocument()
|
||||
* @deprecated Use the new function generateDocument of Facture class
|
||||
* @see Facture::generateDocument()
|
||||
*/
|
||||
function facture_pdf_create(DoliDB $db, Facture $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
|
||||
{
|
||||
|
||||
@ -363,6 +363,28 @@ abstract class ModeleAccountancyCode
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a document onto disk according to template module.
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Facture $object Object invoice
|
||||
* @param string $message Message (not used, deprecated)
|
||||
* @param string $modele Force template to use ('' to not force)
|
||||
* @param Translate $outputlangs objet lang a utiliser pour traduction
|
||||
* @param int $hidedetails Hide details of lines
|
||||
* @param int $hidedesc Hide description
|
||||
* @param int $hideref Hide ref
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @deprecated Use the new function generateDocument of Facture class
|
||||
* @see Societe::generateDocument()
|
||||
*/
|
||||
function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
|
||||
{
|
||||
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
|
||||
|
||||
return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a document for third party
|
||||
@ -374,7 +396,7 @@ abstract class ModeleAccountancyCode
|
||||
* @param Translate $outputlangs Object lang to use for translation
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs)
|
||||
/*function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs)
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
$langs->load("bills");
|
||||
@ -413,7 +435,6 @@ function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs)
|
||||
require_once $dir.'/'.$file;
|
||||
|
||||
$obj = new $classname($db);
|
||||
$obj->message = $message;
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
@ -438,5 +459,5 @@ function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@ -17,6 +17,11 @@
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
|
||||
// TODO This is an action include, not a presentation template.
|
||||
// Move this file into htdocs/core/actions_document.inc.php
|
||||
|
||||
|
||||
// Variable $upload_dir must be defined when entering here
|
||||
|
||||
// Send file/link
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
* $object (invoice, order, ...)
|
||||
* $conf
|
||||
* $langs
|
||||
* $seller, $nuyer
|
||||
* $seller, $buyer
|
||||
* $dateSelector
|
||||
* $forceall (0 by default, 1 for supplier invoices/orders)
|
||||
* $senderissupplier (0 by default, 1 for supplier invoices/orders)
|
||||
@ -259,7 +259,7 @@ if (! empty($conf->margin->enabled))
|
||||
|
||||
/* Init field buying_price and fournprice */
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product?$line->fk_product:0; ?>}, function(data) {
|
||||
if (data && data.length > 0) {
|
||||
if (data && data.length > 0) {
|
||||
var options = '';
|
||||
var trouve=false;
|
||||
$(data).each(function() {
|
||||
@ -302,9 +302,10 @@ if (! empty($conf->margin->enabled))
|
||||
$('#savelinebutton').click(function (e) {
|
||||
return checkEditLine(e, "np_marginRate");
|
||||
});
|
||||
/* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'.
|
||||
$("input[name='np_marginRate']:first").blur(function(e) {
|
||||
return checkEditLine(e, "np_marginRate");
|
||||
});
|
||||
});*/
|
||||
<?php
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
@ -313,9 +314,10 @@ if (! empty($conf->margin->enabled))
|
||||
$('#savelinebutton').click(function (e) {
|
||||
return checkEditLine(e, "np_markRate");
|
||||
});
|
||||
/* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'.
|
||||
$("input[name='np_markRate']:first").blur(function(e) {
|
||||
return checkEditLine(e, "np_markRate");
|
||||
});
|
||||
});*/
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@ -323,7 +325,7 @@ if (! empty($conf->margin->enabled))
|
||||
|
||||
|
||||
/* If margin rate field empty, do nothing. */
|
||||
/* Force content of price_ht to 0 or if a discount is set recalculate it from margin rate */
|
||||
/* Force content of price_ht to 0 or if a discount is set, recalculate it from margin rate */
|
||||
function checkEditLine(e, npRate)
|
||||
{
|
||||
var buying_price = $("input[name='buying_price']:first");
|
||||
@ -332,16 +334,16 @@ if (! empty($conf->margin->enabled))
|
||||
var rate = $("input[name='"+npRate+"']:first");
|
||||
if (rate.val() == '' || (typeof rate.val()) == 'undefined' ) return true;
|
||||
|
||||
if (! $.isNumeric(rate.val().replace(',','.')))
|
||||
if (! $.isNumeric(rate.val().replace(' ','').replace(',','.')))
|
||||
{
|
||||
alert('<?php echo $langs->trans("rateMustBeNumeric"); ?>');
|
||||
alert('<?php echo $langs->transnoentitiesnoconv("rateMustBeNumeric"); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
if (npRate == "np_markRate" && rate.val() >= 100)
|
||||
{
|
||||
alert('<?php echo $langs->trans("markRateShouldBeLesserThan100"); ?>');
|
||||
alert('<?php echo $langs->transnoentitiesnoconv("markRateShouldBeLesserThan100"); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
@ -354,14 +356,20 @@ if (! empty($conf->margin->enabled))
|
||||
{
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
|
||||
/* console.log(npRate+" - "+bpjs+" - "+ratejs); */
|
||||
|
||||
if (npRate == "np_marginRate")
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
price = ((bpjs * (1 + (ratejs / 100))) / (1 - remisejs / 100));
|
||||
else if (npRate == "np_markRate")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
{
|
||||
if (ratejs != 100)
|
||||
{
|
||||
price = ((bpjs / (1 - (ratejs / 100))) / (1 - remisejs / 100));
|
||||
}
|
||||
else price=$("input[name='price_ht']:first").val();
|
||||
}
|
||||
}
|
||||
/* console.log("new price ht = "+price); */
|
||||
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
return true;
|
||||
|
||||
@ -282,7 +282,7 @@ print "</tr>\n";
|
||||
// FILTRES
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" align="left" width="50">';
|
||||
print '<input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.'">';
|
||||
print '<input class="flat" size="4" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
||||
print '</td>';
|
||||
|
||||
// DATE CREATE
|
||||
|
||||
@ -25,3 +25,5 @@ ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32);
|
||||
ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32);
|
||||
|
||||
UPDATE llx_const SET name = __ENCRYPT('ACCOUNTING_EXPORT_PREFIX_SPEC')__ WHERE __DECRYPT('name')__ = 'EXPORT_PREFIX_SPEC';
|
||||
|
||||
ALTER TABLE llx_societe ADD COLUMN model_pdf varchar(255);
|
||||
@ -67,6 +67,7 @@ create table llx_societe
|
||||
fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut
|
||||
note_private text, --
|
||||
note_public text, --
|
||||
model_pdf varchar(255),
|
||||
prefix_comm varchar(5), -- prefix commercial
|
||||
client tinyint DEFAULT 0, -- client 0/1/2
|
||||
fournisseur tinyint DEFAULT 0, -- fournisseur 0/1
|
||||
|
||||
@ -339,7 +339,7 @@ MinLength=Minimum length
|
||||
LanguageFilesCachedIntoShmopSharedMemory=Files .lang loaded in shared memory
|
||||
ExamplesWithCurrentSetup=Examples with current running setup
|
||||
ListOfDirectories=List of OpenDocument templates directories
|
||||
ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.<br><br>Put here full path of directories.<br>Add a carriage return between eah directory.<br>To add a directory of the GED module, add here <b>DOL_DATA_ROOT/ecm/yourdirectoryname</b>.<br><br>Files in those directories must end with <b>.odt</b>.
|
||||
ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.<br><br>Put here full path of directories.<br>Add a carriage return between eah directory.<br>To add a directory of the GED module, add here <b>DOL_DATA_ROOT/ecm/yourdirectoryname</b>.<br><br>Files in those directories must end with <b>.odt</b> or <b>.ods</b>.
|
||||
NumberOfModelFilesFound=Number of ODT/ODS templates files found in those directories
|
||||
ExampleOfDirectoriesForModelGen=Examples of syntax:<br>c:\mydir<br>/home/mydir<br>DOL_DATA_ROOT/ecm/ecmdir
|
||||
FollowingSubstitutionKeysCanBeUsed=<br>To know how to create your odt document templates, before storing them in those directories, read wiki documentation:
|
||||
|
||||
@ -35,8 +35,7 @@ if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande
|
||||
|
||||
|
||||
/**
|
||||
* \class Livraison
|
||||
* \brief Classe de gestion des bons de livraison
|
||||
* Class to manage receptions
|
||||
*/
|
||||
class Livraison extends CommonObject
|
||||
{
|
||||
@ -967,11 +966,14 @@ class Livraison extends CommonObject
|
||||
/**
|
||||
* Create object on disk
|
||||
*
|
||||
* @param string $modele force le modele a utiliser ('' to not force)
|
||||
* @param Translate $outputlangs objet lang a utiliser pour traduction
|
||||
* @return int 0 if KO, 1 if OK
|
||||
* @param string $modele force le modele a utiliser ('' to not force)
|
||||
* @param Translate $outputlangs Object langs to use for output
|
||||
* @param int $hidedetails Hide details of lines
|
||||
* @param int $hidedesc Hide description
|
||||
* @param int $hideref Hide ref
|
||||
* @return int 0 if KO, 1 if OK
|
||||
*/
|
||||
public function generateDocument($modele, $outputlangs='')
|
||||
public function generateDocument($modele, $outputlangs='',$hidedetails=0,$hidedesc=0,$hideref=0)
|
||||
{
|
||||
global $conf,$user,$langs;
|
||||
|
||||
@ -992,7 +994,7 @@ class Livraison extends CommonObject
|
||||
|
||||
$modelpath = "core/modules/livraison/doc/";
|
||||
|
||||
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, 0, 0, 0);
|
||||
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -310,10 +310,11 @@ if (empty($reshook))
|
||||
{
|
||||
$langs->load("other");
|
||||
$upload_dir = $conf->projet->dir_output . "/";
|
||||
$file = $upload_dir . '/' . GETPOST('file');
|
||||
$urlfile=GETPOST('urlfile','alpha');
|
||||
$file = $upload_dir . '/' . $filetodelete;
|
||||
$ret=dol_delete_file($file);
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
|
||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", $urlfile));
|
||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1486,10 +1486,9 @@ class Task extends CommonObject
|
||||
* @param int $hidedetails Hide details of lines
|
||||
* @param int $hidedesc Hide description
|
||||
* @param int $hideref Hide ref
|
||||
* @param HookManager $hookmanager Hook manager instance
|
||||
* @return int 0 if KO, 1 if OK
|
||||
*/
|
||||
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
|
||||
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
|
||||
@ -1012,7 +1012,7 @@ class Societe extends CommonObject
|
||||
$sql .= ', s.status';
|
||||
$sql .= ', s.price_level';
|
||||
$sql .= ', s.tms as date_modification';
|
||||
$sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.client, s.fournisseur';
|
||||
$sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur';
|
||||
$sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6';
|
||||
$sql .= ', s.capital, s.tva_intra';
|
||||
$sql .= ', s.fk_typent as typent_id';
|
||||
@ -1154,6 +1154,7 @@ class Societe extends CommonObject
|
||||
$this->note = $obj->note_private; // TODO Deprecated for backward comtability
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->modelpdf = $obj->model_pdf;
|
||||
$this->default_lang = $obj->default_lang;
|
||||
$this->logo = $obj->logo;
|
||||
|
||||
@ -3342,6 +3343,43 @@ class Societe extends CommonObject
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a document onto disk according to template module.
|
||||
*
|
||||
* @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example.
|
||||
* @param Translate $outputlangs objet lang a utiliser pour traduction
|
||||
* @param int $hidedetails Hide details of lines
|
||||
* @param int $hidedesc Hide description
|
||||
* @param int $hideref Hide ref
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
|
||||
{
|
||||
global $conf,$user,$langs;
|
||||
|
||||
// Positionne le modele sur le nom du modele a utiliser
|
||||
if (! dol_strlen($modele))
|
||||
{
|
||||
if (! empty($conf->global->COMPANY_ADDON_PDF))
|
||||
{
|
||||
$modele = $conf->global->COMPANY_ADDON_PDF;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("Error_COMPANY_ADDON_PDF_NotDefined");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
$modelpath = "core/modules/societe/doc/";
|
||||
|
||||
$result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function used to replace a thirdparty id with another one.
|
||||
* It must be used within a transaction to avoid trouble
|
||||
|
||||
@ -702,56 +702,11 @@ if (empty($reshook))
|
||||
$mode='emailfromthirdparty';
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
|
||||
|
||||
/*
|
||||
* Generate document
|
||||
*/
|
||||
if ($action == 'builddoc') // En get ou en post
|
||||
{
|
||||
if (is_numeric(GETPOST('model')))
|
||||
{
|
||||
$error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php';
|
||||
|
||||
$object->fetch($socid);
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$result=thirdparty_doc_create($db, $object, '', GETPOST('model','alpha'), $outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove file in doc form
|
||||
else if ($action == 'remove_file')
|
||||
{
|
||||
if ($object->fetch($socid))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$langs->load("other");
|
||||
$upload_dir = $conf->societe->dir_output;
|
||||
$file = $upload_dir . '/' . GETPOST('file');
|
||||
$ret=dol_delete_file($file,0,0,0,$object);
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
|
||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
||||
}
|
||||
}
|
||||
// Actions to build doc
|
||||
$id = $socid;
|
||||
$upload_dir = $conf->societe->dir_output;
|
||||
$permissioncreate=$user->rights->societe->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
}
|
||||
|
||||
|
||||
@ -2556,7 +2511,7 @@ else
|
||||
|
||||
$var=true;
|
||||
|
||||
$somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang);
|
||||
print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, '', 0, '', $object->default_lang);
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user