本文整理汇总了PHP中dol_mkdir函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_mkdir函数的具体用法?PHP dol_mkdir怎么用?PHP dol_mkdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dol_mkdir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write_file
/**
* 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);
//.........这里部分代码省略.........
示例2: createFromClone
//.........这里部分代码省略.........
if ($result < 0) {
$this->error = $clone_task->error;
$error++;
}
// End
if (!$error) {
$clone_task_id = $clone_task->id;
$clone_task_ref = $clone_task->ref;
//Note Update
if (!$clone_note) {
$clone_task->note_private = '';
$clone_task->note_public = '';
} else {
$this->db->begin();
$res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES), '_public');
if ($res < 0) {
$this->error .= $clone_task->error;
$error++;
$this->db->rollback();
} else {
$this->db->commit();
}
$this->db->begin();
$res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES), '_private');
if ($res < 0) {
$this->error .= $clone_task->error;
$error++;
$this->db->rollback();
} else {
$this->db->commit();
}
}
//Duplicate file
if ($clone_file) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
//retreive project origin ref to know folder to copy
$projectstatic = new Project($this->db);
$projectstatic->fetch($ori_project_id);
$ori_project_ref = $projectstatic->ref;
if ($ori_project_id != $project_id) {
$projectstatic->fetch($project_id);
$clone_project_ref = $projectstatic->ref;
} else {
$clone_project_ref = $ori_project_ref;
}
$clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref) . "/" . dol_sanitizeFileName($clone_task_ref);
$ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref) . "/" . dol_sanitizeFileName($fromid);
$filearray = dol_dir_list($ori_task_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', '', SORT_ASC, 1);
foreach ($filearray as $key => $file) {
if (!file_exists($clone_task_dir)) {
if (dol_mkdir($clone_task_dir) < 0) {
$this->error .= $langs->trans('ErrorInternalErrorDetected') . ':dol_mkdir';
$error++;
}
}
$rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'], 0, 1);
if (is_numeric($rescopy) && $rescopy < 0) {
$this->error .= $langs->trans("ErrorFailToCopyFile", $ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name']);
$error++;
}
}
}
// clone affectation
if ($clone_affectation) {
$origin_task = new Task($this->db);
$origin_task->fetch($fromid);
foreach (array('internal', 'external') as $source) {
$tab = $origin_task->liste_contact(-1, $source);
$num = count($tab);
$i = 0;
while ($i < $num) {
$clone_task->add_contact($tab[$i]['id'], $tab[$i]['code'], $tab[$i]['source']);
if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
$this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
$error++;
} else {
if ($clone_task->error != '') {
$this->error .= $clone_task->error;
$error++;
}
}
$i++;
}
}
}
if ($clone_time) {
//TODO clone time of affectation
}
}
unset($clone_task->context['createfromclone']);
if (!$error) {
$this->db->commit();
return $clone_task_id;
} else {
$this->db->rollback();
dol_syslog(get_class($this) . "::createFromClone nbError: " . $error . " error : " . $this->error, LOG_ERR);
return -1;
}
}
示例3: write_file
/**
* Function to build pdf onto disk
*
* @param Object $object Object to generate
* @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=OK, 0=KO
*/
function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
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");
$nblignes = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
for ($i = 0; $i < $nblignes; $i++) {
if (empty($object->lines[$i]->fk_product)) {
continue;
}
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product . "/photos/";
$dir = $conf->product->dir_output . '/' . $pdir;
$realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
$filename = $obj['photo'];
//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
$realpath = $dir . $filename;
break;
}
if ($realpath) {
$realpatharray[$i] = $realpath;
}
}
}
if (count($realpatharray) == 0) {
$this->posxpicture = $this->posxtva;
}
if ($conf->facture->dir_output) {
$object->fetch_thirdparty();
$deja_regle = $object->getSommePaiement();
$amount_credit_notes_included = $object->getSumCreditNotesUsed();
$amount_deposits_included = $object->getSumDepositsUsed();
// Definition of $dir and $file
if ($object->specimen) {
$dir = $conf->facture->dir_output;
$file = $dir . "/SPECIMEN.pdf";
} else {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->facture->dir_output . "/" . $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
// Set nblignes with the new facture lines content after hook
$nblignes = count($object->lines);
// Create pdf instance
$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);
//.........这里部分代码省略.........
示例4: init
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories.
* @return int 1 if OK, 0 if KO
*/
function init()
{
global $db, $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$dirodt = DOL_DATA_ROOT . '/produit';
dol_mkdir($dirodt);
dol_copy(dol_buildpath('/pos/frontend/img/noimage.jpg', 0), $dirodt . '/noimage.jpg', 0, 0);
if (empty($conf->global->POS_TICKET) && empty($conf->global->POS_FACTURE)) {
dolibarr_set_const($db, "POS_FACTURE", '1', 'chaine', 0, '', $conf->entity);
}
if (empty($conf->global->POS_MAX_TTC)) {
dolibarr_set_const($db, "POS_MAX_TTC", '100', 'chaine', 0, '', $conf->entity);
}
$sql = array();
$result = $this->load_tables();
return $this->_init($sql);
}
示例5: dol_sanitizeFileName
$object->tva_intra = $_POST["tva_intra"];
$object->commercial_id = $_POST["commercial_id"];
$object->default_lang = $_POST["default_lang"];
$object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
// Gestion du logo de la société
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
if (image_format_supported($_FILES['photo']['name']))
{
dol_mkdir($dir);
if (@is_dir($dir))
{
$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
if (! $result > 0)
{
$errors[] = "ErrorFailedToSaveFile";
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
示例6: foreach
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) {
$pdf->SetCompression(false);
}
// Add all others
foreach ($files as $file) {
// Charge un document PDF depuis un fichier.
$pagecount = $pdf->setSourceFile($file);
for ($i = 1; $i <= $pagecount; $i++) {
$tplidx = $pdf->importPage($i);
$s = $pdf->getTemplatesize($tplidx);
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
$pdf->useTemplate($tplidx);
}
}
// Create output dir if not exists
dol_mkdir($diroutputpdf);
// Save merged file
$filename = strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
if ($option == 'late') {
$filename .= '_' . strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
}
if ($pagecount) {
$now = dol_now();
$file = $diroutputpdf . '/' . $filename . '_' . dol_print_date($now, 'dayhourlog') . '.pdf';
$pdf->Output($file, 'F');
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
} else {
$mesg = '<div class="error">' . $langs->trans('NoPDFAvailableForChecked') . '</div>';
}
示例7: write_file
/**
* Function to build pdf onto disk
*
* @param Object $object Object expedition to generate (or id if old method)
* @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=OK, 0=KO
*/
function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $user, $conf, $langs, $hookmanager;
$object->fetch_thirdparty();
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");
$outputlangs->load("propal");
$outputlangs->load("deliveries");
$outputlangs->load("sendings");
if ($conf->expedition->dir_output) {
// Definition de $dir et $file
if ($object->specimen) {
$dir = $conf->expedition->dir_output . "/sending";
$file = $dir . "/SPECIMEN.pdf";
} else {
$expref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition->dir_output . "/sending/" . $expref;
$file = $dir . "/" . $expref . ".pdf";
}
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir)) {
$nblignes = count($object->lines);
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 0;
// 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));
// Set path to the background PDF File
if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
if (method_exists($pdf, 'AliasNbPages')) {
$pdf->AliasNbPages();
}
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Shipment"));
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();
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$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 = 90;
$tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10;
$tab_height = 130;
$tab_height_newpage = 150;
if (!empty($object->note_public) || !empty($object->tracking_number) && !empty($object->shipping_method_id)) {
$tab_top = 88;
//.........这里部分代码省略.........
示例8: GenericObject
$stdobject = new GenericObject($db);
$stdobject->barcode_type = $fk_barcode_type;
$result = $stdobject->fetch_barcode();
if ($result <= 0) {
$error++;
setEventMessages('Failed to get bar code type information ' . $stdobject->error, $stdobject->errors, 'errors');
}
}
if (!$error) {
$code = $forbarcode;
$generator = $stdobject->barcode_type_coder;
// coder (loaded by fetch_barcode). Engine.
$encoding = strtoupper($stdobject->barcode_type_code);
// code (loaded by fetch_barcode). Example 'ean', 'isbn', ...
$diroutput = $conf->barcode->dir_temp;
dol_mkdir($diroutput);
// Generate barcode
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
foreach ($dirbarcode as $reldir) {
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) {
continue;
}
$result = @(include_once $newdir . $generator . '.modules.php');
if ($result) {
break;
}
}
// Load barcode class for generating barcode image
示例9: build_file
/**
* Build export file.
* File is built into directory $conf->export->dir_temp.'/'.$user->id
* Arrays this->array_export_xxx are already loaded for required datatoexport
*
* @param User $user User that export
* @param string $model Export format
* @param string $datatoexport Name of dataset to export
* @param array $array_selected Filter on array of fields to export
* @param array $array_filterValue Filter on array of fields with a filter
* @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays)
* @return int <0 if KO, >0 if OK
*/
function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '')
{
global $conf, $langs;
$indice = 0;
asort($array_selected);
dol_syslog(get_class($this) . "::" . __FUNCTION__ . " " . $model . ", " . $datatoexport . ", " . implode(",", $array_selected));
// Check parameters or context properties
if (empty($this->array_export_fields) || !is_array($this->array_export_fields)) {
$this->error = "ErrorBadParameter";
return -1;
}
// Creation de la classe d'export du model ExportXXX
$dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
$file = "export_" . $model . ".modules.php";
$classname = "Export" . $model;
require_once $dir . $file;
$objmodel = new $classname($this->db);
if (!empty($sqlquery)) {
$sql = $sqlquery;
} else {
// Define value for indice from $datatoexport
$foundindice = 0;
foreach ($this->array_export_code as $key => $dataset) {
if ($datatoexport == $dataset) {
$indice = $key;
$foundindice++;
//print "Found indice = ".$indice." for dataset=".$datatoexport."\n";
break;
}
}
if (empty($foundindice)) {
$this->error = "ErrorBadParameter can't find dataset " . $datatoexport . " into preload arrays this->array_export_code";
return -1;
}
$sql = $this->build_sql($indice, $array_selected, $array_filterValue);
}
// Run the sql
$this->sqlusedforexport = $sql;
dol_syslog(get_class($this) . "::" . __FUNCTION__ . " sql=" . $sql);
$resql = $this->db->query($sql);
if ($resql) {
//$this->array_export_label[$indice]
$filename = "export_" . $datatoexport;
$filename .= '.' . $objmodel->getDriverExtension();
$dirname = $conf->export->dir_temp . '/' . $user->id;
$outputlangs = dol_clone($langs);
// We clone to have an object we can modify (for example to change output charset by csv handler) without changing original value
// Open file
dol_mkdir($dirname);
$result = $objmodel->open_file($dirname . "/" . $filename, $outputlangs);
if ($result >= 0) {
// Genere en-tete
$objmodel->write_header($outputlangs);
// Genere ligne de titre
$objmodel->write_title($this->array_export_fields[$indice], $array_selected, $outputlangs, $this->array_export_TypeFields[$indice]);
$var = true;
while ($objp = $this->db->fetch_object($resql)) {
$var = !$var;
// Process special operations
if (!empty($this->array_export_special[$indice])) {
foreach ($this->array_export_special[$indice] as $key => $value) {
if (!array_key_exists($key, $array_selected)) {
continue;
}
// Field not selected
// Operation NULLIFNEG
if ($this->array_export_special[$indice][$key] == 'NULLIFNEG') {
//$alias=$this->array_export_alias[$indice][$key];
$alias = str_replace(array('.', '-'), '_', $key);
if ($objp->{$alias} < 0) {
$objp->{$alias} = '';
}
}
// Operation ZEROIFNEG
if ($this->array_export_special[$indice][$key] == 'ZEROIFNEG') {
//$alias=$this->array_export_alias[$indice][$key];
$alias = str_replace(array('.', '-'), '_', $key);
if ($objp->{$alias} < 0) {
$objp->{$alias} = '0';
}
}
}
}
// end of special operation processing
$objmodel->write_record($array_selected, $objp, $outputlangs, $this->array_export_TypeFields[$indice]);
}
// Genere en-tete
//.........这里部分代码省略.........
示例10: write_file
/**
* Fonction generant le rapport sur le disque
*
* @param string $_dir Directory
* @param string $number Number
* @param Translate $outputlangs Lang output object
* @return int 1=ok, 0=ko
*/
function write_file($_dir, $number, $outputlangs)
{
global $user, $conf, $langs;
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
$sav_charset_output = $outputlangs->charset_output;
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("products");
$outputlangs->load("compta");
$dir = $_dir . "/" . get_exdir($number, 2, 1) . $number;
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 . "/bordereau-" . $number . ".pdf";
// Create PDF instance
$pdf = pdf_getInstance($this->format);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->Open();
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->transnoentities("CheckReceipt") . " " . $number);
$pdf->SetSubject($outputlangs->transnoentities("CheckReceipt"));
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt") . " " . $number);
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) {
$pdf->SetCompression(false);
}
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
// Left, Top, Right
$pdf->SetAutoPageBreak(1, 0);
$nboflines = count($this->lines);
// Define nb of page
$pages = intval($nboflines / $this->line_per_page);
if ($nboflines % $this->line_per_page > 0) {
$pages++;
}
if ($pages == 0) {
// force to build at least one page if report has no lines
$pages = 1;
}
$pdf->AddPage();
$pagenb++;
$this->Header($pdf, $pagenb, $pages, $outputlangs);
$this->Body($pdf, $pagenb, $pages, $outputlangs);
// Pied de page
$this->_pagefoot($pdf, '', $outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($_file, 'F');
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($_file, octdec($conf->global->MAIN_UMASK));
}
$outputlangs->charset_output = $sav_charset_output;
return 1;
// Pas d'erreur
}
示例11: migrate_product_photospath
/**
* Migrate file from old path to new one for product $product
*
* @param Product $product Object product
* @return void
*/
function migrate_product_photospath($product)
{
global $conf;
$dir = $conf->product->multidir_output[$product->entity];
$origin = $dir . '/' . get_exdir($product->id, 2) . $product->id . "/photos";
$destin = $dir . '/' . dol_sanitizeFileName($product->ref);
$error = 0;
$origin_osencoded = dol_osencode($origin);
$destin_osencoded = dol_osencode($destin);
dol_mkdir($destin);
if (dol_is_dir($origin)) {
$handle = opendir($origin_osencoded);
if (is_resource($handle)) {
while (($file = readdir($handle)) != false) {
if ($file != '.' && $file != '..' && is_dir($origin_osencoded . '/' . $file)) {
$thumbs = opendir($origin_osencoded . '/' . $file);
if (is_resource($thumbs)) {
dol_mkdir($destin . '/' . $file);
while (($thumb = readdir($thumbs)) != false) {
dol_move($origin . '/' . $file . '/' . $thumb, $destin . '/' . $file . '/' . $thumb);
}
// dol_delete_dir($origin.'/'.$file);
}
} else {
if (dol_is_file($origin . '/' . $file)) {
dol_move($origin . '/' . $file, $destin . '/' . $file);
}
}
}
}
}
}
示例12: array
print ' ' . $langs->trans("YouMustCreateItAndAllowServerToWrite");
print '</td><td>';
print '<font class="error">' . $langs->trans("Error") . '</font>';
print "</td></tr>";
print '<tr><td colspan="2"><br>' . $langs->trans("CorrectProblemAndReloadPage", $_SERVER['PHP_SELF'] . '?testget=ok') . '</td></tr>';
} else {
//ODT templates
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$srcroot = $main_dir . '/install/doctemplates';
$destroot = $main_data_dir . '/doctemplates';
$docs = array('thirdparties' => 'thirdparty', 'proposals' => 'proposal', 'orders' => 'order', 'invoices' => 'invoice', 'projects' => 'project', 'tasks' => 'task_summary');
foreach ($docs as $cursordir => $cursorfile) {
$src = $srcroot . '/' . $cursordir . '/template_' . $cursorfile . '.odt';
$dirodt = $destroot . '/' . $cursordir;
$dest = $dirodt . '/template_' . $cursorfile . '.odt';
dol_mkdir($dirodt);
$result = dol_copy($src, $dest, 0, 0);
if ($result < 0) {
print '<tr><td colspan="2"><br>' . $langs->trans('ErrorFailToCopyFile', $src, $dest) . '</td></tr>';
}
}
}
}
}
// Table prefix
$main_db_prefix = !empty($db_prefix) ? $db_prefix : 'llx_';
// Force https
$main_force_https = GETPOST("main_force_https") && (GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1) ? '1' : '0';
// Use alternative directory
$main_use_alt_dir = GETPOST("main_use_alt_dir") && (GETPOST("main_use_alt_dir") == "on" || GETPOST("main_use_alt_dir") == 1) ? '' : '//';
// Alternative root directory name
示例13: pdf_getInstance
/**
* Return a PDF instance object. We create a FPDI instance that instantiate TCPDF.
*
* @param string $format Array(width,height). Keep empty to use default setup.
* @param string $metric Unit of format ('mm')
* @param string $pagetype 'P' or 'l'
* @return TPDF PDF object
*/
function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P')
{
global $conf;
// Define constant for TCPDF
if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
define('K_TCPDF_EXTERNAL_CONFIG', 1);
// this avoid using tcpdf_config file
define('K_PATH_CACHE', DOL_DATA_ROOT . '/admin/temp/');
define('K_PATH_URL_CACHE', DOL_DATA_ROOT . '/admin/temp/');
dol_mkdir(K_PATH_CACHE);
define('K_BLANK_IMAGE', '_blank.png');
define('PDF_PAGE_FORMAT', 'A4');
define('PDF_PAGE_ORIENTATION', 'P');
define('PDF_CREATOR', 'TCPDF');
define('PDF_AUTHOR', 'TCPDF');
define('PDF_HEADER_TITLE', 'TCPDF Example');
define('PDF_HEADER_STRING', "by Dolibarr ERP CRM");
define('PDF_UNIT', 'mm');
define('PDF_MARGIN_HEADER', 5);
define('PDF_MARGIN_FOOTER', 10);
define('PDF_MARGIN_TOP', 27);
define('PDF_MARGIN_BOTTOM', 25);
define('PDF_MARGIN_LEFT', 15);
define('PDF_MARGIN_RIGHT', 15);
define('PDF_FONT_NAME_MAIN', 'helvetica');
define('PDF_FONT_SIZE_MAIN', 10);
define('PDF_FONT_NAME_DATA', 'helvetica');
define('PDF_FONT_SIZE_DATA', 8);
define('PDF_FONT_MONOSPACED', 'courier');
define('PDF_IMAGE_SCALE_RATIO', 1.25);
define('HEAD_MAGNIFICATION', 1.1);
define('K_CELL_HEIGHT_RATIO', 1.25);
define('K_TITLE_MAGNIFICATION', 1.3);
define('K_SMALL_RATIO', 2 / 3);
define('K_THAI_TOPCHARS', true);
define('K_TCPDF_CALLS_IN_HTML', true);
define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
}
if (!empty($conf->global->MAIN_USE_FPDF) && !empty($conf->global->MAIN_DISABLE_FPDI)) {
return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together";
}
// We use by default TCPDF else FPDF
if (empty($conf->global->MAIN_USE_FPDF)) {
require_once TCPDF_PATH . 'tcpdf.php';
} else {
require_once FPDF_PATH . 'fpdf.php';
}
// We need to instantiate tcpdi or fpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features).
if (empty($conf->global->MAIN_DISABLE_TCPDI)) {
require_once TCPDI_PATH . 'tcpdi.php';
} else {
if (empty($conf->global->MAIN_DISABLE_FPDI)) {
require_once FPDI_PATH . 'fpdi.php';
}
}
//$arrayformat=pdf_getFormat();
//$format=array($arrayformat['width'],$arrayformat['height']);
//$metric=$arrayformat['unit'];
// Protection and encryption of pdf
if (empty($conf->global->MAIN_USE_FPDF) && !empty($conf->global->PDF_SECURITY_ENCRYPTION)) {
/* Permission supported by TCPDF
- print : Print the document;
- modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
- copy : Copy or otherwise extract text and graphics from the document;
- annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);
- fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;
- extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);
- assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;
- print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
- owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
*/
if (class_exists('TCPDI')) {
$pdf = new TCPDI($pagetype, $metric, $format);
} else {
if (class_exists('FPDI')) {
$pdf = new FPDI($pagetype, $metric, $format);
} else {
$pdf = new TCPDF($pagetype, $metric, $format);
}
}
// For TCPDF, we specify permission we want to block
$pdfrights = array('modify', 'copy');
$pdfuserpass = '';
// Password for the end user
$pdfownerpass = NULL;
// Password of the owner, created randomly if not defined
$pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass);
} else {
if (class_exists('TCPDI')) {
$pdf = new TCPDI($pagetype, $metric, $format);
} else {
if (class_exists('FPDI')) {
//.........这里部分代码省略.........
示例14: init
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options = '')
{
global $conf, $langs;
// We disable this to prevent pb of modules not correctly disabled
//$this->remove($options);
//ODT template
$src = DOL_DOCUMENT_ROOT . '/install/doctemplates/thirdparties/template_thirdparty.odt';
$dirodt = DOL_DATA_ROOT . '/doctemplates/thirdparties';
$dest = $dirodt . '/template_thirdparty.odt';
if (file_exists($src) && !file_exists($dest)) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_mkdir($dirodt);
$result = dol_copy($src, $dest, 0, 0);
if ($result < 0) {
$langs->load("errors");
$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}
$sql = array();
return $this->_init($sql, $options);
}
示例15: array
}
if (!isset($num)) {
$sql .= " OR b.num_releve is null";
}
$sql .= " AND b.fk_account = ba.rowid";
$sql .= $db->order("b.num_releve, b.datev, b.datec", "ASC");
// We add date of creation to have correct order when everything is done the same day
//print $sql;
$resql = $db->query($sql);
if ($resql) {
$balancebefore = array();
$numrows = $db->num_rows($resql);
if ($numrows > 0) {
// Open file
print 'Open file ' . $filename . ' into directory ' . $dirname . "\n";
dol_mkdir($dirname);
$result = $objmodel->open_file($dirname . "/" . $filename, $outputlangs);
if ($result < 0) {
print 'Failed to create file ' . $filename . ' into dir ' . $dirname . '.' . "\n";
return -1;
}
// Genere en-tete
$objmodel->write_header($outputlangs);
// Genere ligne de titre
$objmodel->write_title($array_fields, $array_selected, $outputlangs, $array_export_TypeFields);
}
$i = 0;
while ($i < $numrows) {
$thirdparty = '';
$accountelem = '';
$comment = '';