本文整理汇总了PHP中Commande::fetch_contact方法的典型用法代码示例。如果您正苦于以下问题:PHP Commande::fetch_contact方法的具体用法?PHP Commande::fetch_contact怎么用?PHP Commande::fetch_contact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commande
的用法示例。
在下文中一共展示了Commande::fetch_contact方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HookManager
/**
* Function to build a document on disk using the generic odt module.
*
* @param Commande $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->commande->dir_output) {
// If $object is id instead of object
if (!is_object($object)) {
$id = $object;
$object = new Commande($this->db);
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error($this->db, $object->error);
return -1;
}
}
$dir = $conf->commande->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->commande->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
//.........这里部分代码省略.........
示例2: Commande
/**
* Function to build a document on disk using the generic odt module.
*
* @param Commande $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;
if (empty($srctemplatepath)) {
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
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->commande->dir_output) {
// If $object is id instead of object
if (!is_object($object)) {
$id = $object;
$object = new Commande($this->db);
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error($this->db, $object->error);
return -1;
}
}
$dir = $conf->commande->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('/\\.odt/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';
$file = $dir . '/' . $newfiletmp . '.odt';
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
dol_mkdir($conf->commande->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 ($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->nom, '__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);
// Line of free text
$newfreetext = '';
$paramfreetext = 'COMMANDE_FREE_TEXT';
if (!empty($conf->global->{$paramfreetext})) {
$newfreetext = make_substitutions($conf->global->{$paramfreetext}, $substitutionarray);
}
// Open and load template
require_once ODTPHP_PATH . 'odf.php';
$odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->commande->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}'));
// 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 freetext
try {
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
} catch (OdfException $e) {
//.........这里部分代码省略.........