本文整理汇总了PHP中HookManager::initHooks方法的典型用法代码示例。如果您正苦于以下问题:PHP HookManager::initHooks方法的具体用法?PHP HookManager::initHooks怎么用?PHP HookManager::initHooks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HookManager
的用法示例。
在下文中一共展示了HookManager::initHooks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sprintf
/**
* Fonction generant la rapport sur le disque
*
* @param string $_dir repertoire
* @param int $month mois du rapport
* @param int $year annee du rapport
* @param string $outputlangs Lang output object
* @return int <0 if KO, >0 if OK
*/
function write_file($_dir, $month, $year, $outputlangs)
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
global $user, $langs, $conf;
$socid = 0;
if ($user->societe_id) {
$socid = $user->societe_id;
}
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$this->month = $month;
$this->year = $year;
$dir = $_dir . '/' . $year;
if (!is_dir($dir)) {
$result = dol_mkdir($dir);
if ($result < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
$month = sprintf("%02d", $month);
$year = sprintf("%04d", $year);
$file = $dir . "/payments-" . $year . "-" . $month . ".pdf";
// Add pdfgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
// Must be after pdf_getInstance
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
$num = 0;
$lines = array();
$sql = "SELECT p.datep as dp, f.facnumber";
//$sql .= ", c.libelle as paiement_type, p.num_paiement";
$sql .= ", c.code as paiement_code, p.num_paiement";
$sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount ";
$sql .= ", pf.amount as pf_amount ";
$sql .= ", p.rowid as prowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "paiement as p, " . MAIN_DB_PREFIX . "facture as f,";
$sql .= " " . MAIN_DB_PREFIX . "c_paiement as c, " . MAIN_DB_PREFIX . "paiement_facture as pf,";
$sql .= " " . MAIN_DB_PREFIX . "societe as s";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
$sql .= " AND f.entity = " . $conf->entity;
$sql .= " AND p.fk_paiement = c.id ";
$sql .= " AND p.datep BETWEEN '" . $this->db->idate(dol_get_first_day($year, $month)) . "' AND '" . $this->db->idate(dol_get_last_day($year, $month)) . "'";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
}
if (!empty($socid)) {
$sql .= " AND s.rowid = " . $socid;
}
$sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
dol_syslog(get_class($this) . "::write_file", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$i = 0;
$var = True;
while ($i < $num) {
$objp = $this->db->fetch_object($result);
$var = !$var;
$lines[$i][0] = $objp->facnumber;
$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp), "day", false, $outputlangs, true);
$lines[$i][2] = $langs->transnoentities("PaymentTypeShort" . $objp->paiement_code);
$lines[$i][3] = $objp->num_paiement;
$lines[$i][4] = price($objp->paiement_amount);
$lines[$i][5] = price($objp->facture_amount);
$lines[$i][6] = price($objp->pf_amount);
$lines[$i][7] = $objp->prowid;
$i++;
}
} else {
//.........这里部分代码省略.........
示例2: HookManager
/**
* Function to build a document on disk using the generic odt module.
*
* @param Propale $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO
*/
function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath)) {
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
// Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
if ($conf->supplier_proposal->dir_output) {
// If $object is id instead of object
if (!is_object($object)) {
$id = $object;
$object = new SupplierProposal($this->db);
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error($this->db, $object->error);
return -1;
}
}
$dir = $conf->supplier_proposal->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/" . $objectref;
}
$file = $dir . "/" . $objectref . ".odt";
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
if (file_exists($dir)) {
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
$filename = $newfiletmp . '.' . dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '.' . $newfileformat;
} else {
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->propal->dir_temp=".$conf->propal->dir_temp;
dol_mkdir($conf->supplier_proposal->dir_temp);
// If BILLING contact defined on invoice, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'BILLING');
if (count($arrayidcontact) > 0) {
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
if (!empty($usecontact)) {
// On peut utiliser le nom de la societe du contact
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$socobject = $object->contact;
} else {
$socobject = $object->client;
}
} else {
$socobject = $object->client;
}
// Make substitution
$substitutionarray = array('__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, '__TOTAL_VAT__' => $object->total_vat);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray);
//.........这里部分代码省略.........
示例3: Canvas
$object->getCanvas($socid);
$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
if (! empty($canvas))
{
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
$objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('thirdparty', 'card', $canvas);
}
// Security check
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('thirdpartycard'));
/*
* Actions
*/
$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors);
if (empty($reshook))
{
if (GETPOST('getcustomercode'))
{
// We defined value code_client
示例4: HookManager
/**
* Fonction generant le projet sur le disque
*
* @param Project $object Object project a generer
* @param Translate $outputlangs Lang output object
* @return int 1 if OK, <=0 if KO
*/
function write_file($object, $outputlangs)
{
global $conf, $hookmanager, $langs, $user;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("projects");
if ($conf->projet->dir_output) {
//$nblignes = count($object->lines); // This is set later with array of tasks
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output;
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/" . $objectref;
}
$file = $dir . "/" . $objectref . ".pdf";
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir)) {
// Add pdfgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
// Must be after pdf_getInstance
$heightforinfotot = 50;
// Height reserved to output the info and total part
$heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5;
// Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8;
// Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Complete object by loading several other informations
$task = new Task($this->db);
$tasksarray = $task->getTasksArray(0, 0, $object->id);
if (!$object->id > 0) {
$tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
}
$object->lines = $tasksarray;
$nblignes = count($object->lines);
$pdf->Open();
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Project"));
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Project"));
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
$pdf->SetCompression(false);
}
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
// Left, Top, Right
// New page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, '');
// Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 50;
$tab_height = 200;
$tab_top_newpage = 40;
$tab_height_newpage = 210;
// Affiche notes
if (!empty($object->note_public)) {
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
$height_note = $nexY - ($tab_top - 2);
//.........这里部分代码省略.........
示例5: delete
/**
* Delete a third party from database and all its dependencies (contacts, rib...)
*
* @param int $id Id of third party to delete
* @return int <0 if KO, 0 if nothing done, >0 if OK
*/
function delete($id) {
global $user, $langs, $conf;
require_once(DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php");
dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
$error = 0;
// Test if child exists
//$objectisused = $this->isObjectUsed($this->rowid); // TODO A reactivier
if (empty($objectisused)) {
require_once(DOL_DOCUMENT_ROOT . "/categories/class/categorie.class.php");
$static_cat = new Categorie($this->db);
$toute_categs = array();
// Fill $toute_categs array with an array of (type => array of ("Categorie" instance))
if ($this->client || $this->prospect) {
$toute_categs ['societe'] = $static_cat->containing($this->id, 2);
}
if ($this->fournisseur) {
$toute_categs ['fournisseur'] = $static_cat->containing($this->id, 1);
}
// Remove each "Categorie"
foreach ($toute_categs as $type => $categs_type) {
foreach ($categs_type as $cat) {
$cat->del_type($this, $type);
}
}
return parent::delete();
// TODO Supprimer les contacts
// Remove contacts
if (!$error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "socpeople";
$sql.= " WHERE fk_soc = " . $id;
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
if (!$this->db->query($sql)) {
$error++;
$this->error .= $this->db->lasterror();
dol_syslog(get_class($this) . "::delete erreur -1 " . $this->error, LOG_ERR);
}
}
// Update link in member table
if (!$error) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "adherent";
$sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id;
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
if (!$this->db->query($sql)) {
$error++;
$this->error .= $this->db->lasterror();
dol_syslog(get_class($this) . "::delete erreur -1 " . $this->error, LOG_ERR);
}
}
// Remove ban
if (!$error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib";
$sql.= " WHERE fk_soc = " . $id;
dol_syslog(get_class($this) . "::Delete sql=" . $sql, LOG_DEBUG);
if (!$this->db->query($sql)) {
$error++;
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::Delete erreur -2 " . $this->error, LOG_ERR);
}
}
// Removed extrafields
//$result=$this->deleteExtraFields($this);
//if ($result < 0) $error++;
if (!$error) {
// Additionnal action by hooks
include_once(DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php');
$hookmanager = new HookManager($this->db);
$hookmanager->initHooks(array('thirdparty_extrafields'));
$parameters = array();
$action = 'delete';
$reshook = $hookmanager->executeHooks('deleteThirdparty', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (!empty($hookmanager->error)) {
$error++;
$this->error = $hookmanager->error;
}
}
// Remove third party
if (!$error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe";
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
if (!$this->db->query($sql)) {
//.........这里部分代码省略.........
示例6: HookManager
/**
* Function to build a document on disk using the generic odt module.
*
* @param Project $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @return int 1 if OK, <=0 if KO
*/
function write_file($object, $outputlangs, $srctemplatepath)
{
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath)) {
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
// Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("projects");
if ($conf->projet->dir_output) {
// If $object is id instead of object
if (!is_object($object)) {
$id = $object;
$object = new Project($this->db);
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error($this->db, $object->error);
return -1;
}
}
$dir = $conf->projet->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/" . $objectref;
}
$file = $dir . "/" . $objectref . ".odt";
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
if (file_exists($dir)) {
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
$filename = $newfiletmp . '.' . dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '.' . $newfileformat;
} else {
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
dol_mkdir($conf->projet->dir_temp);
$socobject = $object->thirdparty;
// Make substitution
$substitutionarray = array('__FROM_NAME__' => $this->emetteur->nom, '__FROM_EMAIL__' => $this->emetteur->email);
complete_substitutions_array($substitutionarray, $langs, $object);
// Open and load template
require_once ODTPHP_PATH . 'odf.php';
try {
$odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->projet->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}'));
} catch (Exception $e) {
$this->error = $e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
//print html_entity_decode($odfHandler->__toString());
//print exit;
// Make substitutions into odt of user info
$tmparray = $this->get_substitutionarray_user($user, $outputlangs);
foreach ($tmparray as $key => $value) {
try {
if (preg_match('/logo$/', $key)) {
//var_dump($value);exit;
if (file_exists($value)) {
$odfHandler->setImage($key, $value);
//.........这里部分代码省略.........
示例7: createFromOrder
/**
* Load an object from an order and create a new invoice into database
*
* @param Object $object Object source
* @return int <0 if KO, 0 if nothing done, 1 if OK
*/
function createFromOrder($object)
{
global $conf, $user, $langs;
$error = 0;
// Closed order
$this->date = dol_now();
$this->source = 0;
$num = count($object->lines);
for ($i = 0; $i < $num; $i++) {
$line = new FactureLigne($this->db);
$line->libelle = $object->lines[$i]->libelle;
$line->desc = $object->lines[$i]->desc;
//$line->price = $object->lines[$i]->price;
$line->subprice = $object->lines[$i]->subprice;
$line->total_ht = $object->lines[$i]->total_ht;
$line->total_tva = $object->lines[$i]->total_tva;
$line->total_ttc = $object->lines[$i]->total_ttc;
$line->tva_tx = $object->lines[$i]->tva_tx;
$line->localtax1_tx = $object->lines[$i]->localtax1_tx;
$line->localtax2_tx = $object->lines[$i]->localtax2_tx;
$line->qty = $object->lines[$i]->qty;
$line->fk_remise_except = $object->lines[$i]->fk_remise_except;
$line->remise_percent = $object->lines[$i]->remise_percent;
$line->fk_product = $object->lines[$i]->fk_product;
$line->info_bits = $object->lines[$i]->info_bits;
$line->product_type = $object->lines[$i]->product_type;
$line->rang = $object->lines[$i]->rang;
$line->special_code = $object->lines[$i]->special_code;
$line->fk_parent_line = $object->lines[$i]->fk_parent_line;
$this->lines[$i] = $line;
}
$this->socid = $object->socid;
$this->fk_project = $object->fk_project;
$this->cond_reglement_id = $object->cond_reglement_id;
$this->mode_reglement_id = $object->mode_reglement_id;
$this->availability_id = $object->availability_id;
$this->demand_reason_id = $object->demand_reason_id;
$this->date_livraison = $object->date_livraison;
$this->fk_delivery_address = $object->fk_delivery_address;
$this->contact_id = $object->contactid;
$this->ref_client = $object->ref_client;
$this->note = $object->note;
$this->note_public = $object->note_public;
$this->origin = $object->element;
$this->origin_id = $object->id;
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && !empty($object->other_linked_objects)) {
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user);
if ($ret > 0) {
// Actions hooked (by external module)
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
$hookmanager->initHooks(array('invoicedao'));
$parameters = array('objFrom' => $object);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
$error++;
}
if (!$error) {
return 1;
} else {
return -1;
}
} else {
return -1;
}
}
示例8: left_menu
/**
* Show left menu bar
*
* @param array $menu_array_before Table of menu entries to show before entries of menu handler
* @param string $helppagename Name of wiki page for help ('' by default).
* Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage
* For other external page: http://server/url
* @param string $moresearchform Search Form Permanent Supplemental
* @param array $menu_array_after Table of menu entries to show after entries of menu handler
* @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules.
* @param string $title Title of web page
* @return void
*/
function left_menu($menu_array_before, $helppagename = '', $moresearchform = '', $menu_array_after = '', $leftmenuwithoutmainarea = 0, $title = '') {
global $user, $conf, $langs, $db;
global $hookmanager;
$searchform = '';
$bookmarks = '';
// Instantiate hooks of thirdparty module
if (!is_object($hookmanager)) {
include_once(DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php');
$hookmanager = new HookManager($db);
}
$hookmanager->initHooks(array('searchform', 'leftblock'));
print "\n";
// Define $searchform
if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire) {
$langs->load("companies");
$searchform.=printSearchForm(DOL_URL_ROOT . '/societe/societe.php', DOL_URL_ROOT . '/societe/societe.php', img_object('', 'company') . ' ' . $langs->trans("ThirdParties"), 'soc', 'socname');
}
if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_CONTACT && $user->rights->societe->lire) {
$langs->load("companies");
$searchform.=printSearchForm(DOL_URL_ROOT . '/contact/list.php', DOL_URL_ROOT . '/contact/list.php', img_object('', 'contact') . ' ' . $langs->trans("Contacts"), 'contact', 'contactname');
}
if ((($conf->product->enabled && $user->rights->produit->lire) || ($conf->service->enabled && $user->rights->service->lire))
&& $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE) {
$langs->load("products");
$searchform.=printSearchForm(DOL_URL_ROOT . '/product/liste.php', DOL_URL_ROOT . '/product/liste.php', img_object('', 'product') . ' ' . $langs->trans("Products") . "/" . $langs->trans("Services"), 'products', 'sall');
}
if ($conf->adherent->enabled && $conf->global->MAIN_SEARCHFORM_ADHERENT && $user->rights->adherent->lire) {
$langs->load("members");
$searchform.=printSearchForm(DOL_URL_ROOT . '/adherents/liste.php', DOL_URL_ROOT . '/adherents/liste.php', img_object('', 'user') . ' ' . $langs->trans("Members"), 'member', 'sall');
}
// Execute hook printSearchForm
$parameters = array();
$searchform.=$hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks
// Define $bookmarks
if ($conf->bookmark->enabled && $user->rights->bookmark->lire) {
include_once (DOL_DOCUMENT_ROOT . '/bookmarks/bookmarks.lib.php');
$langs->load("bookmarks");
$bookmarks = printBookmarksList($db, $langs);
}
// Load the top menu manager (only if not already done)
if (!class_exists('MenuLeft')) {
$menufound = 0;
$dirmenus = array_merge(array("/core/menus/"), $conf->menus_modules);
foreach ($dirmenus as $dirmenu) {
$menufound = dol_include_once($dirmenu . "standard/" . $left_menu);
if ($menufound)
break;
}
if (!$menufound) { // If failed to include, we try with standard
$top_menu = 'eldy_backoffice.php';
include_once(DOL_DOCUMENT_ROOT . "/core/menus/standard/" . $top_menu);
}
}
/*
// Left column
print '<!--Begin left area - menu '.$left_menu.'-->'."\n";
print '<div class = "row">'."\n";
print '<div class = "three columns hide-on-phones">'."\n";
//$menuleft=new MenuLeft($db,$menu_array_before,$menu_array_after);
//$menuleft->showmenu(); // output menu_array and menu found in database
// Show other forms
if ($searchform)
{
print "\n";
print "<!-- Begin SearchForm -->\n";
print '<div id = "blockvmenusearch" class = "blockvmenusearch">'."\n";
print $searchform;
print '</div>'."\n";
print "<!-- End SearchForm -->\n";
}
// More search form
//.........这里部分代码省略.........
示例9: HookManager
/**
* Function to build a document on disk using the generic odt module.
*
* @param Societe $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO
*/
function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath)) {
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
// Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("projects");
if ($conf->societe->multidir_output[$object->entity]) {
$dir = $conf->societe->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->id);
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/" . $objectref;
}
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
if (file_exists($dir)) {
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\\.od(s|t)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
$filename = $newfiletmp . '.' . dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '.' . $newfileformat;
} else {
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir . '/' . $filename;
$object->builddoc_filename = $filename;
// For triggers
//print "newfileformat=".$newfileformat;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
//exit;
dol_mkdir($conf->societe->multidir_temp[$object->entity]);
// Open and load template
require_once ODTPHP_PATH . 'odf.php';
try {
$odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity], 'ZIP_PROXY' => 'PclZipProxy', 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}'));
} catch (Exception $e) {
$this->error = $e->getMessage();
return -1;
}
//print $odfHandler->__toString()."\n";
// Make substitutions into odt of user info
$tmparray = $this->get_substitutionarray_user($user, $outputlangs);
//var_dump($tmparray); exit;
foreach ($tmparray as $key => $value) {
try {
if (preg_match('/logo$/', $key)) {
//var_dump($value);exit;
if (file_exists($value)) {
$odfHandler->setImage($key, $value);
} else {
$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
} else {
//print $key.' '.$value;exit;
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
} catch (OdfException $e) {
// setVars failed, probably because key not found
}
}
// Make substitutions into odt of mysoc info
$tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
//.........这里部分代码省略.........
示例10: date
function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, &$TtoGenerate)
{
global $user, $langs, $conf, $mysoc, $db, $hookmanager;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("products");
if ($conf->facture->dir_output) {
$dir = $conf->lcr->dir_output . "/";
$file = $dir . "" . 'lcr_' . date('YmdHis') . ".pdf";
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir)) {
$pdf = pdf_getInstance($this->format);
$pdf->SetAutoPageBreak(1, 0);
$this->_showLCR($pdf, $object, $outputlangs, $TtoGenerate);
$pdf->Close();
$pdf->Output($file, 'F');
// Add pdfgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
return 1;
// Pas d'erreur
} else {
$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
} else {
$this->error = $langs->trans("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
return 0;
}
$this->error = $langs->trans("ErrorUnknown");
return 0;
// Erreur par defaut
}
示例11: empty
{
$_GET['id_fourn'] = $_GET['search_fourn_id'];
$_POST['id_fourn'] = $_POST['search_fourn_id'];
$_REQUEST['id_fourn'] = $_REQUEST['search_fourn_id'];
}
// Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service&fournisseur',$fieldvalue,'product&product','','',$fieldtype);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('pricesuppliercard'));
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
if (! $sortfield) $sortfield="s.nom";
if (! $sortorder) $sortorder="ASC";
/*
* Actions
*/
if ($action == 'remove_pf')
{
示例12: restrictedArea
$dbtable = 'propal';
}
}
if ($user->societe_id) {
$socid = $user->societe_id;
}
$result = restrictedArea($user, $module, $objectid, $dbtable);
$object = new Propal($db);
// Load object
if ($id > 0 || !empty($ref)) {
$ret = $object->fetch($id, $ref);
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('propalcard'));
/*
* Actions
*/
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x")) {
$search_categ = '';
$search_user = '';
$search_sale = '';
$search_ref = '';
$search_refcustomer = '';
$search_societe = '';
$search_montant_ht = '';
$year = '';
$month = '';
}
示例13: array
$date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]);
$date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]);
// Date for local PHP server
$date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["date_end_delyday"], $_REQUEST["date_end_delyyear"]);
if ($action == 'create') {
if (is_array($selected) == false) {
$mesgs = array('<div class="error">' . $langs->trans('Error_OrderNotChecked') . '</div>');
} else {
$origin = GETPOST('origin');
$originid = GETPOST('originid');
}
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('orderstoinvoicesupplier'));
/*
* Actions
*/
if (($action == 'create' || $action == 'add') && empty($mesgs)) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php';
if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
}
$langs->load('bills');
$langs->load('products');
$langs->load('main');
if (isset($_GET['orders_to_invoice'])) {
$orders_id = $_GET['orders_to_invoice'];
$n = count($orders_id);
$i = 0;
示例14: HookManager
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require("../../main.inc.php");
$langs->load("main");
$langs->load("install");
$langs->load("other");
// Security check
global $dolibarr_main_demo;
if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page',1,1,1);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('demo'));
$demoprofiles=array(
array('default'=>'-1', 'key'=>'profdemofun','label'=>'DemoFundation',
'disablemodules'=>'banque,barcode,boutique,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,facture,ficheinter,fournisseur,mailmanspip,prelevement,product,projet,propal,propale,service,societe,stock,tax',
'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png'),
array('default'=>'0', 'key'=>'profdemofun2','label'=>'DemoFundation2',
'disablemodules'=>'barcode,boutique,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,facture,ficheinter,fournisseur,mailmanspip,prelevement,product,projet,propal,propale,service,societe,stock,tax',
'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png'),
array('default'=>'1', 'key'=>'profdemoservonly','label'=>'DemoCompanyServiceOnly',
'disablemodules'=>'adherent,barcode,boutique,cashdesk,categorie,don,expedition,externalsite,mailmanspip,prelevement,product,stock',
'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot8.png'),
array('default'=>'-1','key'=>'profdemoshopwithdesk','label'=>'DemoCompanyShopWithCashDesk',
'disablemodules'=>'adherent,boutique,categorie,don,externalsite,ficheinter,mailmanspip,prelevement,product,stock',
'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot2.png'),
array('default'=>'0', 'key'=>'profdemoprodstock','label'=>'DemoCompanyProductAndStocks',
示例15: update
/**
* Update a record into database
*
* @param int $id Id of product
* @param User $user Object user making update
* @param int $notrigger Disable triggers
* @return int 1 if OK, -1 if ref already exists, -2 if other error
*/
function update($id, $user, $notrigger=false)
{
global $langs, $conf;
$error=0;
$this->db->begin();
// Verification parametres
if (! $this->libelle) $this->libelle = 'MISSING LABEL';
// Clean parameters
$this->ref = dol_string_nospecial(trim($this->ref));
$this->libelle = trim($this->libelle);
$this->description = trim($this->description);
$this->note = trim($this->note);
$this->weight = price2num($this->weight);
$this->weight_units = trim($this->weight_units);
$this->length = price2num($this->length);
$this->length_units = trim($this->length_units);
$this->surface = price2num($this->surface);
$this->surface_units = trim($this->surface_units);
$this->volume = price2num($this->volume);
$this->volume_units = trim($this->volume_units);
if (empty($this->tva_tx)) $this->tva_tx = 0;
if (empty($this->tva_npr)) $this->tva_npr = 0;
//Local taxes
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
if (empty($this->finished)) $this->finished = 0;
if (empty($this->country_id)) $this->country_id = 0;
$this->accountancy_code_buy = trim($this->accountancy_code_buy);
$this->accountancy_code_sell= trim($this->accountancy_code_sell);
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
$sql.= " SET label = '" . $this->db->escape($this->libelle) ."'";
$sql.= ",ref = '" . $this->ref ."'";
$sql.= ",tva_tx = " . $this->tva_tx;
$sql.= ",recuperableonly = " . $this->tva_npr;
//Local taxes
$sql.= ",localtax1_tx = " . $this->localtax1_tx;
$sql.= ",localtax2_tx = " . $this->localtax2_tx;
$sql.= ",tosell = " . $this->status;
$sql.= ",tobuy = " . $this->status_buy;
$sql.= ",finished = " . ($this->finished<0 ? "null" : $this->finished);
$sql.= ",weight = " . ($this->weight!='' ? "'".$this->weight."'" : 'null');
$sql.= ",weight_units = " . ($this->weight_units!='' ? "'".$this->weight_units."'": 'null');
$sql.= ",length = " . ($this->length!='' ? "'".$this->length."'" : 'null');
$sql.= ",length_units = " . ($this->length_units!='' ? "'".$this->length_units."'" : 'null');
$sql.= ",surface = " . ($this->surface!='' ? "'".$this->surface."'" : 'null');
$sql.= ",surface_units = " . ($this->surface_units!='' ? "'".$this->surface_units."'" : 'null');
$sql.= ",volume = " . ($this->volume!='' ? "'".$this->volume."'" : 'null');
$sql.= ",volume_units = " . ($this->volume_units!='' ? "'".$this->volume_units."'" : 'null');
$sql.= ",seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->seuil_stock_alerte."'" : "null");
$sql.= ",description = '" . $this->db->escape($this->description) ."'";
$sql.= ",customcode = '" . $this->db->escape($this->customcode) ."'";
$sql.= ",fk_country = " . ($this->country_id > 0 ? $this->country_id : 'null');
$sql.= ",note = '" . $this->db->escape($this->note) ."'";
$sql.= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
$sql.= ",accountancy_code_buy = '" . $this->accountancy_code_buy."'";
$sql.= ",accountancy_code_sell= '" . $this->accountancy_code_sell."'";
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."update sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$this->id = $id;
// Multilangs
if($conf->global->MAIN_MULTILANGS)
{
if ( $this->setMultiLangs() < 0)
{
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
return -2;
}
}
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->initHooks(array('productdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
$result=$this->insertExtraFields();
//.........这里部分代码省略.........