本文整理汇总了PHP中dol_delete_preview函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_delete_preview函数的具体用法?PHP dol_delete_preview怎么用?PHP dol_delete_preview使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dol_delete_preview函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Delete invoice
*
* @param int $rowid Id of invoice to delete. If empty, we delete current instance of invoice
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
*/
function delete($rowid = 0, $notrigger = 0)
{
global $user, $langs, $conf;
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
if (!$rowid) {
$rowid = $this->id;
}
dol_syslog(get_class($this) . "::delete rowid=" . $rowid, LOG_DEBUG);
// TODO Test if there is at least on payment. If yes, refuse to delete.
$error = 0;
$this->db->begin();
if (!$error && !$notrigger) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('BILL_DELETE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
if (!$error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
}
if (!$error) {
// If invoice was converted into a discount not yet consumed, we remove discount
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'societe_remise_except';
$sql .= ' WHERE fk_facture_source = ' . $rowid;
$sql .= ' AND fk_facture_line IS NULL';
$resql = $this->db->query($sql);
// If invoice has consumned discounts
$this->fetch_lines();
$list_rowid_det = array();
foreach ($this->lines as $key => $invoiceline) {
$list_rowid_det[] = $invoiceline->rowid;
}
// Consumned discounts are freed
if (count($list_rowid_det)) {
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except';
$sql .= ' SET fk_facture = NULL, fk_facture_line = NULL';
$sql .= ' WHERE fk_facture_line IN (' . join(',', $list_rowid_det) . ')';
dol_syslog(get_class($this) . "::delete sql=" . $sql);
if (!$this->db->query($sql)) {
$this->error = $this->db->error() . " sql=" . $sql;
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
return -5;
}
}
// Delete invoice line
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE fk_facture = ' . $rowid;
if ($this->db->query($sql) && $this->delete_linked_contact()) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facture WHERE rowid = ' . $rowid;
$resql = $this->db->query($sql);
if ($resql) {
// On efface le repertoire de pdf provisoire
$ref = dol_sanitizeFileName($this->ref);
if ($conf->facture->dir_output) {
$dir = $conf->facture->dir_output . "/" . $ref;
$file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
if (file_exists($file)) {
$ret = dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = $langs->trans("ErrorCanNotDeleteFile", $file);
$this->db->rollback();
return 0;
}
}
if (file_exists($dir)) {
if (!dol_delete_dir_recursive($dir)) {
$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
$this->db->rollback();
return 0;
}
}
}
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror() . " sql=" . $sql;
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
return -6;
}
} else {
$this->error = $this->db->lasterror() . " sql=" . $sql;
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
//.........这里部分代码省略.........
示例2: delete
/**
* Delete invoice
*
* @param int $rowid Id of invoice to delete. If empty, we delete current instance of invoice
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int $idwarehouse Id warehouse to use for stock change.
* @return int <0 if KO, >0 if OK
*/
function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1)
{
global $user, $langs, $conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
if (empty($rowid)) {
$rowid = $this->id;
}
dol_syslog(get_class($this) . "::delete rowid=" . $rowid, LOG_DEBUG);
// TODO Test if there is at least one payment. If yes, refuse to delete.
$error = 0;
$this->db->begin();
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('BILL_DELETE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
// Removed extrafields
if (!$error) {
$result = $this->deleteExtraFields();
if ($result < 0) {
$error++;
dol_syslog(get_class($this) . "::delete error deleteExtraFields " . $this->error, LOG_ERR);
}
}
if (!$error) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
}
if (!$error) {
// If invoice was converted into a discount not yet consumed, we remove discount
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'societe_remise_except';
$sql .= ' WHERE fk_facture_source = ' . $rowid;
$sql .= ' AND fk_facture_line IS NULL';
$resql = $this->db->query($sql);
// If invoice has consumned discounts
$this->fetch_lines();
$list_rowid_det = array();
foreach ($this->lines as $key => $invoiceline) {
$list_rowid_det[] = $invoiceline->rowid;
}
// Consumned discounts are freed
if (count($list_rowid_det)) {
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except';
$sql .= ' SET fk_facture = NULL, fk_facture_line = NULL';
$sql .= ' WHERE fk_facture_line IN (' . join(',', $list_rowid_det) . ')';
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->error() . " sql=" . $sql;
$this->db->rollback();
return -5;
}
}
// If we decrement stock on invoice validation, we increment
if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) {
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php';
$langs->load("agenda");
$num = count($this->lines);
for ($i = 0; $i < $num; $i++) {
if ($this->lines[$i]->fk_product > 0) {
$mouvP = new MouvementStock($this->db);
$mouvP->origin =& $this;
// We decrease stock for product
if ($this->type == self::TYPE_CREDIT_NOTE) {
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref));
} else {
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref));
}
// we use 0 for price, to not change the weighted average value
}
}
}
// Delete invoice line
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE fk_facture = ' . $rowid;
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
if ($this->db->query($sql) && $this->delete_linked_contact()) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'facture WHERE rowid = ' . $rowid;
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
// On efface le repertoire de pdf provisoire
$ref = dol_sanitizeFileName($this->ref);
if ($conf->facture->dir_output && !empty($this->ref)) {
$dir = $conf->facture->dir_output . "/" . $ref;
$file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
if (file_exists($file)) {
$ret = dol_delete_preview($this);
//.........这里部分代码省略.........
示例3: delete
/**
* Delete proposal
*
* @param User $user Object user that delete
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int 1 if ok, otherwise if error
*/
function delete($user, $notrigger = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
$error = 0;
$this->db->begin();
if (!$error && !$notrigger) {
// Call triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('PROPAL_DELETE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// End call triggers
}
if (!$error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "propaldet WHERE fk_propal = " . $this->id;
if ($this->db->query($sql)) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "propal WHERE rowid = " . $this->id;
if ($this->db->query($sql)) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) {
$error++;
}
if (!$error) {
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->propal->dir_output) {
$dir = $conf->propal->dir_output . "/" . $ref;
$file = $dir . "/" . $ref . ".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = 'ErrorFailToDeleteFile';
$this->db->rollback();
return 0;
}
}
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->db->rollback();
return 0;
}
}
}
}
if (!$error) {
dol_syslog(get_class($this) . "::delete {$this->id} by {$user->id}", LOG_DEBUG);
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
return 0;
}
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
示例4: delete
/**
* Delete proposal
*
* @param User $user Object user that delete
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int 1 if ok, otherwise if error
*/
function delete($user, $notrigger = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$error = 0;
$this->db->begin();
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('PROPAL_DELETE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "propaldet WHERE fk_propal = " . $this->id;
if ($this->db->query($sql)) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "propal WHERE rowid = " . $this->id;
if ($this->db->query($sql)) {
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) {
$error++;
}
if (!$error) {
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->propal->dir_output && !empty($this->ref)) {
$dir = $conf->propal->dir_output . "/" . $ref;
$file = $dir . "/" . $ref . ".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = 'ErrorFailToDeleteFile';
$this->errors = array('ErrorFailToDeleteFile');
$this->db->rollback();
return 0;
}
}
if (file_exists($dir)) {
$res = @dol_delete_dir_recursive($dir);
if (!$res) {
$this->error = 'ErrorFailToDeleteDir';
$this->errors = array('ErrorFailToDeleteDir');
$this->db->rollback();
return 0;
}
}
}
}
// Removed extrafields
if (!$error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$result = $this->deleteExtraFields();
if ($result < 0) {
$error++;
$errorflag = -4;
dol_syslog(get_class($this) . "::delete erreur " . $errorflag . " " . $this->error, LOG_ERR);
}
}
}
if (!$error) {
dol_syslog(get_class($this) . "::delete " . $this->id . " by " . $user->id, LOG_DEBUG);
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return 0;
}
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -3;
}
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -2;
}
} else {
$this->db->rollback();
return -1;
}
}
示例5: delete
/**
* Delete the customer order
*
* @param User $user User object
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <=0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$error = 0;
$this->db->begin();
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('ORDER_DELETE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
//TODO: Check for error after each action. If one failed we rollback, don't waste time to do action if previous fail
if (!$error) {
// Delete order details
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . "commandedet WHERE fk_commande = " . $this->id;
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$error++;
$this->errors[] = $this->db->lasterror();
}
// Delete order
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . "commande WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$error++;
$this->errors[] = $this->db->lasterror();
}
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) {
$error++;
}
// Remove extrafields
if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$result = $this->deleteExtraFields();
if ($result < 0) {
$error++;
dol_syslog(get_class($this) . "::delete error -4 " . $this->error, LOG_ERR);
}
}
// On efface le repertoire de pdf provisoire
$comref = dol_sanitizeFileName($this->ref);
if ($conf->commande->dir_output && !empty($this->ref)) {
$dir = $conf->commande->dir_output . "/" . $comref;
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->db->rollback();
return 0;
}
}
if (file_exists($dir)) {
if (!dol_delete_dir_recursive($dir)) {
$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
$this->db->rollback();
return 0;
}
}
}
}
if (!$error) {
dol_syslog(get_class($this) . "::delete {$this->id} by {$user->id}", LOG_DEBUG);
$this->db->commit();
return 1;
} else {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= $this->error ? ', ' . $errmsg : $errmsg;
}
$this->db->rollback();
return -1 * $error;
}
}
示例6: facture_pdf_create
/**
* Create a document onto disk according to template module.
*
* @param DoliDB $db Database handler
* @param Object $object Object invoice
* @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
* @param HookManager $hookmanager Hook manager instance
* @return int <0 if KO, >0 if OK
*/
function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $hookmanager = false)
{
global $conf, $user, $langs;
$langs->load("bills");
$error = 0;
// Increase limit for PDF build
$err = error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
$srctemplatepath = '';
// Positionne le modele sur le nom du modele a utiliser
if (!dol_strlen($modele)) {
if (!empty($conf->global->FACTURE_ADDON_PDF)) {
$modele = $conf->global->FACTURE_ADDON_PDF;
} else {
$modele = 'crabe';
}
}
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// Search template files
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('doc', 'pdf') as $prefix) {
$file = $prefix . "_" . $modele . ".modules.php";
// On verifie l'emplacement du modele
$file = dol_buildpath($reldir . "core/modules/facture/doc/" . $file, 0);
if (file_exists($file)) {
$filefound = 1;
$classname = $prefix . '_' . $modele;
break;
}
}
if ($filefound) {
break;
}
}
// Charge le modele
if ($filefound) {
require_once $file;
$obj = new $classname($db);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output;
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) {
$outputlangs->charset_output = $sav_charset_output;
// We delete old preview
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
dol_delete_preview($object);
// Success in building document. We build meta file.
dol_meta_create($object);
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($db);
$result = $interface->run_triggers('BILL_BUILDDOC', $object, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_print_error($db, "facture_pdf_create Error: " . $obj->error);
return -1;
}
} else {
dol_print_error('', $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file));
return -1;
}
}
示例7: delete
/**
* Delete intervetnion
*
* @param User $user Object user who delete
* @param int $notrigger Disable trigger
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$error = 0;
$this->db->begin();
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) {
$this->error = 'ErrorFailToDeleteLinkedContact';
$error++;
}
if ($error) {
$this->db->rollback();
return -1;
}
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "fichinterdet";
$sql .= " WHERE fk_fichinter = " . $this->id;
dol_syslog("Fichinter::delete", LOG_DEBUG);
if ($this->db->query($sql)) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "fichinter";
$sql .= " WHERE rowid = " . $this->id;
$sql .= " AND entity = " . $conf->entity;
dol_syslog("Fichinter::delete", LOG_DEBUG);
if ($this->db->query($sql)) {
// Remove directory with files
$fichinterref = dol_sanitizeFileName($this->ref);
if ($conf->ficheinter->dir_output) {
$dir = $conf->ficheinter->dir_output . "/" . $fichinterref;
$file = $conf->ficheinter->dir_output . "/" . $fichinterref . "/" . $fichinterref . ".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = $langs->trans("ErrorCanNotDeleteFile", $file);
return 0;
}
}
if (file_exists($dir)) {
if (!dol_delete_dir_recursive($dir)) {
$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
return 0;
}
}
}
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_DELETE', $user);
if ($result < 0) {
$error++;
$this->db->rollback();
return -1;
}
// End call triggers
}
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -2;
}
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
}
示例8: don_create
/**
* Cree un don sur disque en fonction du modele de DON_ADDON_PDF
*
* @param DoliDB $db Databse handler
* @param int $id Id donation
* @param string $message Message
* @param string $modele Force le modele a utiliser ('' par defaut)
* @param Translate $outputlangs Object langs
* @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
*/
function don_create($db, $id, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $conf, $langs;
$langs->load("bills");
$eror = 0;
// Increase limit for PDF build
$err = error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
$srctemplatepath = '';
// Set template to use
if (!dol_strlen($modele)) {
if (!empty($conf->global->DON_ADDON_MODEL)) {
$modele = $conf->global->DON_ADDON_MODEL;
} else {
print $langs->trans("Error") . " " . $langs->trans("Error_DON_ADDON_MODEL_NotDefined");
return 0;
}
}
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// Search template files
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('html', 'doc', 'pdf') as $prefix) {
$file = $prefix . "_" . preg_replace('/^html_/', '', $modele) . ".modules.php";
// On verifie l'emplacement du modele
$file = dol_buildpath($reldir . "core/modules/dons/" . $file, 0);
if (file_exists($file)) {
$filefound = 1;
$classname = $prefix . '_' . $modele;
break;
}
}
if ($filefound) {
break;
}
}
// Charge le modele
if ($filefound) {
require_once $file;
$object = new Don($db);
$object->fetch($id);
$classname = $modele;
$obj = new $classname($db);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output;
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
$outputlangs->charset_output = $sav_charset_output;
// we delete preview files
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_delete_preview($object);
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_syslog("Erreur dans don_create");
dol_print_error($db, $obj->error);
return 0;
}
} else {
print $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file);
return 0;
}
}
示例9: don_create
/**
* Cree un don sur disque en fonction du modele de DON_ADDON_PDF
*
* @param DoliDB $db Databse handler
* @param int $id Id donation
* @param string $message Message
* @param string $modele Force le modele a utiliser ('' par defaut)
* @param Translate $outputlangs Object langs
* @return int 0 if KO, 1 if OK
*/
function don_create($db, $id, $message, $modele, $outputlangs)
{
global $conf, $langs;
$langs->load("bills");
$dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/";
// Set template to use
if (!dol_strlen($modele)) {
if ($conf->global->DON_ADDON_MODEL) {
$modele = $conf->global->DON_ADDON_MODEL;
} else {
print $langs->trans("Error") . " " . $langs->trans("Error_DON_ADDON_MODEL_NotDefined");
return 0;
}
}
// Charge le modele
$file = $modele . ".modules.php";
if (file_exists($dir . $file)) {
$object = new Don($db);
$object->fetch($id);
require_once $dir . $file;
$classname = $modele;
$module = new $classname($db);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output;
if ($module->write_file($object, $outputlangs) > 0) {
$outputlangs->charset_output = $sav_charset_output;
// we delete preview files
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
dol_delete_preview($object);
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_syslog("Erreur dans don_create");
dol_print_error($db, $module->error);
return 0;
}
} else {
print $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $dir . $file);
return 0;
}
}
示例10: commonGenerateDocument
//.........这里部分代码省略.........
// Increase limit for PDF build
$err = error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// Search template files
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('doc', 'pdf') as $prefix) {
$file = $prefix . "_" . $modele . ".modules.php";
// On verifie l'emplacement du modele
$file = dol_buildpath($reldir . $modelspath . $file, 0);
if (file_exists($file)) {
$filefound = 1;
$classname = $prefix . '_' . $modele;
break;
}
}
if ($filefound) {
break;
}
}
// If generator was found
if ($filefound) {
require_once $file;
$obj = new $classname($this->db);
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
if ($obj->type == 'odt' && empty($srctemplatepath)) {
$varfortemplatedir = $obj->scandir;
if ($varfortemplatedir && !empty($conf->global->{$varfortemplatedir})) {
$dirtoscan = $conf->global->{$varfortemplatedir};
$listoffiles = array();
// Now we add first model found in directories scanned
$listofdir = explode(',', $dirtoscan);
foreach ($listofdir as $key => $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]);
continue;
}
if (is_dir($tmpdir)) {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\\.od(s|t)$', '', 'name', SORT_ASC, 0);
if (count($tmpfiles)) {
$listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
}
if (count($listoffiles)) {
foreach ($listoffiles as $record) {
$srctemplatepath = $record['fullname'];
break;
}
}
}
if (empty($srctemplatepath)) {
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
return -1;
}
}
if ($obj->type == 'odt' && !empty($srctemplatepath)) {
if (!dol_is_file($srctemplatepath)) {
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
return -1;
}
}
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output;
if ($obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
$outputlangs->charset_output = $sav_charset_output;
// We delete old preview
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_delete_preview($this);
// Success in building document. We build meta file.
dol_meta_create($this);
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_print_error($this->db, "Error generating document for " . __CLASS__ . ". Error: " . $obj->error, $obj->errors);
return -1;
}
} else {
$this->error = $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file);
dol_print_error('', $this->error);
return -1;
}
}
示例11: fichinter_create
/**
* Create an intervention document on disk using template defined into FICHEINTER_ADDON_PDF
*
* @param DoliDB $db objet base de donnee
* @param Object $object Object fichinter
* @param string $modele force le modele a utiliser ('' par defaut)
* @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, 1 if OK
*/
function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $conf, $langs, $user;
$langs->load("ficheinter");
$error = 0;
$srctemplatepath = '';
// Positionne modele sur le nom du modele de fichinter a utiliser
if (!dol_strlen($modele)) {
if (!empty($conf->global->FICHEINTER_ADDON_PDF)) {
$modele = $conf->global->FICHEINTER_ADDON_PDF;
} else {
$modele = 'soleil';
}
}
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// Search template files
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('doc', 'pdf') as $prefix) {
$file = $prefix . "_" . $modele . ".modules.php";
// On verifie l'emplacement du modele
$file = dol_buildpath($reldir . "core/modules/fichinter/doc/" . $file, 0);
if (file_exists($file)) {
$filefound = 1;
$classname = $prefix . '_' . $modele;
break;
}
}
if ($filefound) {
break;
}
}
// Charge le modele
if ($filefound) {
require_once $file;
$obj = new $classname($db);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output;
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
$outputlangs->charset_output = $sav_charset_output;
// We delete old preview
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_delete_preview($object);
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_print_error($db, "fichinter_pdf_create Error: " . $obj->error);
return 0;
}
} else {
print $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file);
return 0;
}
}
示例12: delivery_order_pdf_create
/**
* Create object on disk
*
* @param DoliDB $db objet base de donnee
* @param Object $object object delivery
* @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
*/
function delivery_order_pdf_create($db, $object, $modele, $outputlangs = '')
{
global $conf, $user, $langs;
$langs->load("deliveries");
$error = 0;
$srctemplatepath = '';
// Positionne modele sur le nom du modele de bon de livraison a utiliser
if (!dol_strlen($modele)) {
if (!empty($conf->global->LIVRAISON_ADDON_PDF)) {
$modele = $conf->global->LIVRAISON_ADDON_PDF;
} else {
$modele = 'typhon';
}
}
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// Search template files
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('doc', 'pdf') as $prefix) {
$file = $prefix . "_" . $modele . ".modules.php";
// On verifie l'emplacement du modele
$file = dol_buildpath($reldir . "core/modules/livraison/pdf/" . $file, 0);
if (file_exists($file)) {
$filefound = 1;
$classname = $prefix . '_' . $modele;
break;
}
}
if ($filefound) {
break;
}
}
// Charge le modele
if ($filefound) {
require_once $file;
$obj = new $classname($db);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output;
if ($obj->write_file($object, $outputlangs) > 0) {
$outputlangs->charset_output = $sav_charset_output;
// we delete preview files
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_delete_preview($object);
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface = new Interfaces($db);
$result = $interface->run_triggers('DELIVERY_BUILDDOC', $object, $user, $langs, $conf);
if ($result < 0) {
$error++;
$obj->errors = $interface->errors;
}
// Fin appel triggers
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_syslog("Erreur dans delivery_order_pdf_create");
dol_print_error($db, $obj->error);
return 0;
}
} else {
print $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file);
return 0;
}
}
示例13: supplier_invoice_pdf_create
/**
* Create a document onto disk according to template model.
*
* @param DoliDB $db Database handler
* @param Object $object Object supplier invoice
* @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs Object 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, 1 if OK
*/
function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $conf, $user, $langs;
$langs->load("suppliers");
$error = 0;
// Increase limit for PDF build
$err = error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
$srctemplatepath = '';
// Set the model on the model name to use
if (!dol_strlen($modele)) {
if (!empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) {
$modele = $conf->global->INVOICE_SUPPLIER_ADDON_PDF;
} else {
$modele = 'canelle';
}
}
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// Search template files
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('doc', 'pdf') as $prefix) {
$file = $prefix . "_" . $modele . ".modules.php";
// We checked the location of the model
$file = dol_buildpath($reldir . "core/modules/supplier_invoice/pdf/" . $file, 0);
if (file_exists($file)) {
$filefound = 1;
$classname = $prefix . '_' . $modele;
break;
}
}
if ($filefound) {
break;
}
}
// Load the model
if ($filefound) {
require_once $file;
$obj = new $classname($db, $object);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output;
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
$outputlangs->charset_output = $sav_charset_output;
// we delete preview files
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_delete_preview($object);
// Calls triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface = new Interfaces($db);
$result = $interface->run_triggers('BILL_SUPPLIER_BUILDDOC', $object, $user, $langs, $conf);
if ($result < 0) {
$error++;
$obj->errors = $interface->errors;
}
// End calls triggers
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_syslog("Erreur dans supplier_invoice_pdf_create");
dol_print_error($db, $obj->error);
return 0;
}
} else {
if (!$conf->global->INVOICE_SUPPLIER_ADDON_PDF) {
print $langs->trans("Error") . " " . $langs->trans("Error_INVOICE_SUPPLIER_ADDON_PDF_NotDefined");
} else {
print $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file);
}
return 0;
}
}
示例14: delete
/**
* Delete the customer order
*
* @param User $user User object
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <=0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
$error = 0;
$this->db->begin();
if (!$error && !$notrigger) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('ORDER_DELETE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
if (!$error) {
// Delete order details
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . "commandedet WHERE fk_commande = " . $this->id;
dol_syslog(get_class($this) . "::delete sql=" . $sql);
if (!$this->db->query($sql)) {
dol_syslog(get_class($this) . "::delete error", LOG_ERR);
$error++;
}
// Delete order
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . "commande WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
if (!$this->db->query($sql)) {
dol_syslog(get_class($this) . "::delete error", LOG_ERR);
$error++;
}
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) {
$error++;
}
// On efface le repertoire de pdf provisoire
$comref = dol_sanitizeFileName($this->ref);
if ($conf->commande->dir_output) {
$dir = $conf->commande->dir_output . "/" . $comref;
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
if (file_exists($file)) {
dol_delete_preview($this);
if (!dol_delete_file($file, 0, 0, 0, $this)) {
$this->error = $langs->trans("ErrorCanNotDeleteFile", $file);
$this->db->rollback();
return 0;
}
}
if (file_exists($dir)) {
if (!dol_delete_dir_recursive($dir)) {
$this->error = $langs->trans("ErrorCanNotDeleteDir", $dir);
$this->db->rollback();
return 0;
}
}
}
}
if (!$error) {
dol_syslog(get_class($this) . "::delete {$this->id} by {$user->id}", LOG_DEBUG);
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
示例15: commonGenerateDocument
/**
* Common function for all objects extending CommonObject for generating documents
*
* @param string $modelspath Relative folder where models are placed
* @param string $modele Model to use
* @param Translate $outputlangs Language to use
* @param int $hidedetails 1 to hide details. 0 by default
* @param int $hidedesc 1 to hide product description. 0 by default
* @param int $hideref 1 to hide product reference. 0 by default
* @return int 1 if OK -1 if KO
*/
protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref)
{
global $conf, $langs;
$srctemplatepath = '';
// Increase limit for PDF build
$err = error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// Search template files
$file = '';
$classname = '';
$filefound = 0;
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('doc', 'pdf') as $prefix) {
$file = $prefix . "_" . $modele . ".modules.php";
// On verifie l'emplacement du modele
$file = dol_buildpath($reldir . $modelspath . $file, 0);
if (file_exists($file)) {
$filefound = 1;
$classname = $prefix . '_' . $modele;
break;
}
}
if ($filefound) {
break;
}
}
// Charge le modele
if ($filefound) {
require_once $file;
$obj = new $classname($this->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.
$sav_charset_output = $outputlangs->charset_output;
if ($obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
$outputlangs->charset_output = $sav_charset_output;
// We delete old preview
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_delete_preview($this);
// Success in building document. We build meta file.
dol_meta_create($this);
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_print_error($this->db, "Error generating document for " . __CLASS__ . ". Error: " . $obj->error);
return -1;
}
} else {
dol_print_error('', $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file));
return -1;
}
}