/** * Constructor * * @param DoliDB $db Database handler * @param Conf $conf Handler de conf * @param Translate $langs Handler de langue * @param User $user Handler du user connecte */ function __construct($db, $conf, $langs, $user) { $this->id = "Perso"; $this->length = $langs->trans("SetupPerso"); $this->db = $db; $this->conf = $conf; $this->langs = $langs; $this->user = $user; if (empty($conf->global->USER_PASSWORD_PATTERN)) { // default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation. dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1', 'chaine', 0, '', $conf->entity); } $this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $this->Min = strtolower($this->Maj); $this->Nb = "0123456789"; $this->Spe = "!@#\$%&*()_-+={}[]\\|:;'/"; $this->Ambi = array("1", "I", "l", "|", "O", "0"); $tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN); $this->length2 = $tabConf[0]; $this->NbMaj = $tabConf[1]; $this->NbNum = $tabConf[2]; $this->NbSpe = $tabConf[3]; $this->NbRepeat = $tabConf[4]; $this->WithoutAmbi = $tabConf[5]; if ($this->WithoutAmbi) { $this->Maj = str_replace($this->Ambi, "", $this->Maj); $this->Min = str_replace($this->Ambi, "", $this->Min); $this->Nb = str_replace($this->Ambi, "", $this->Nb); $this->Spe = str_replace($this->Ambi, "", $this->Spe); } $this->All = str_shuffle($this->Maj . $this->Min . $this->Nb . $this->Spe); //$this->All = $this->Maj. $this->Min. $this->Nb. $this->Spe; //$this->All = $this->Spe; }
/** * Return description of module * * @param Translate $langs Object langs * @return string Description of module */ function info($langs) { global $conf; global $form; $langs->load("companies"); $tooltip = ''; $texte = '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; $texte .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; $texte .= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">'; $texte .= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">'; $texte .= '<table class="nobordernopadding" width="100%">'; $s1 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="' . $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER . '">', $tooltip, 1, 1); $s2 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="' . $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER . '">', $tooltip, 1, 1); $texte .= '<tr><td>' . $langs->trans("ModuleCompanyCode" . $this->nom, $s1, $s2) . "<br>\n"; $texte .= '</td>'; $texte .= '<td align="left"> <input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button"></td>'; $texte .= '</tr></table>'; $texte .= '</form>'; return $texte; }
/** * testBank * * @return string */ public function testLang() { global $conf, $user, $langs, $db; $conf = $this->savconf; $user = $this->savuser; $langs = $this->savlangs; $db = $this->savdb; include_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php'; $filesarray = scandir(DOL_DOCUMENT_ROOT . '/langs'); foreach ($filesarray as $key => $code) { if (!preg_match('/^[a-z]+_[A-Z]+$/', $code)) { continue; } print 'Check language file for lang code=' . $code . "\n"; $tmplangs = new Translate('', $conf); $langcode = $code; $tmplangs->setDefaultLang($langcode); $tmplangs->load("main"); $result = $tmplangs->trans("SeparatorDecimal"); print __METHOD__ . " SeparatorDecimal=" . $result . "\n"; $this->assertContains($result, array('.', ',', '/', ' ', '', 'None'), 'Error for decimal separator for lang code ' . $code); // Note that ، that is coma for RTL languages is not supported $result = $tmplangs->trans("SeparatorThousand"); print __METHOD__ . " SeparatorThousand=" . $result . "\n"; $this->assertContains($result, array('.', ',', '/', ' ', '', 'None', 'Space'), 'Error for thousand separator for lang code ' . $code); // Note that ، that is coma for RTL languages is not supported // Test java string contains only d,M,y,/,-,. and not m,... $result = $tmplangs->trans("FormatDateShortJava"); print __METHOD__ . " FormatDateShortJava=" . $result . "\n"; $this->assertRegExp('/^[dMy\\/\\-\\.]+$/', $result, 'FormatDateShortJava KO for lang code ' . $code); $result = $tmplangs->trans("FormatDateShortJavaInput"); print __METHOD__ . " FormatDateShortJavaInput=" . $result . "\n"; $this->assertRegExp('/^[dMy\\/\\-\\.]+$/', $result, 'FormatDateShortJavaInput KO for lang code ' . $code); unset($tmplangs); } return; }
/** * Return array of translated months or selected month. * This replace old function monthArrayOrSelected. * * @param Translate $outputlangs Object langs * @return array Month string or array if selected < 0 */ function monthArray($outputlangs) { $montharray = array(1 => $outputlangs->trans("January"), 2 => $outputlangs->trans("February"), 3 => $outputlangs->trans("March"), 4 => $outputlangs->trans("April"), 5 => $outputlangs->trans("May"), 6 => $outputlangs->trans("June"), 7 => $outputlangs->trans("July"), 8 => $outputlangs->trans("August"), 9 => $outputlangs->trans("September"), 10 => $outputlangs->trans("October"), 11 => $outputlangs->trans("November"), 12 => $outputlangs->trans("December")); return $montharray; }
/** * Return description of a module * * @param Translate $langs Lang object to use for output * @return string Description */ function info($langs) { global $conf, $langs; $langs->load("companies"); $langs->load("errors"); $form = new Form($this->db); $texte = $this->description . ".<br>\n"; $texte .= '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; $texte .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; $texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">'; if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) { $texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">'; $texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">'; $texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">'; } $texte .= '<table class="nobordernopadding" width="100%">'; // List of directories area $texte .= '<tr><td>'; $texttitle = $langs->trans("ListOfDirectories"); $listofdir = explode(',', preg_replace('/[\\r\\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))); $listoffiles = array(); 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)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); } else { $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\\.(ods|odt)'); if (count($tmpfiles)) { $listoffiles = array_merge($listoffiles, $tmpfiles); } } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys $texthelp .= '<br>' . $langs->trans("FollowingSubstitutionKeysCanBeUsed") . '<br>'; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; $texte .= '<textarea class="flat" cols="60" name="value1">'; $texte .= $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH; $texte .= '</textarea>'; $texte .= '</div><div style="display: inline-block; vertical-align: middle;">'; $texte .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button">'; $texte .= '<br></div></div>'; // Scan directories if (count($listofdir)) { $texte .= $langs->trans("NumberOfModelFilesFound") . ': <b>' . count($listoffiles) . '</b>'; if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) { // Model for creation $liste = ModelePDFSupplierProposal::liste_modeles($this->db); $texte .= '<table width="50%;">'; $texte .= '<tr>'; $texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalCreate") . '</td>'; $texte .= '<td colspan="">'; $texte .= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT); $texte .= "</td></tr>"; $texte .= '<tr>'; $texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalToBill") . '</td>'; $texte .= '<td colspan="">'; $texte .= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL); $texte .= "</td></tr>"; $texte .= '<tr>'; $texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalClosed") . '</td>'; $texte .= '<td colspan="">'; $texte .= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED); $texte .= "</td></tr>"; $texte .= '</table>'; } } $texte .= '</td>'; $texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">'; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); $texte .= '</td>'; $texte .= '</tr>'; $texte .= '</table>'; $texte .= '</form>'; return $texte; }
/** Return description of module * * @param Translate $langs Object langs * @return string Description of module */ function info($langs) { $langs->load("companies"); return $langs->trans("LeopardNumRefModelDesc"); }
/** * Return font size to use for PDF generation * * @param Translate $outputlangs Output langs object * @return int Size of font to use */ function pdf_getPDFFontSize($outputlangs) { $size = 10; // By default, for FPDI or ISO language on TCPDF if (class_exists('TCPDF')) { if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') { $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); } } return $size; }
/** * Returns formated reduction * * @param int $reduction Reduction percentage * @param Translate $langs Output language * @return string Formated reduction */ function dol_print_reduction($reduction, $langs) { $string = ''; if ($reduction == 100) { $string = $langs->trans("Offered"); } else { $string = $reduction . '%'; } return $string; }
/** * Return the max number delivery delay in day * * @param Translate $langs Language object * @return Translated string */ function getMaxDeliveryTimeDay($langs) { if (empty($this->lines)) { return ''; } $obj = new ProductFournisseur($this->db); $nb = 0; foreach ($this->lines as $line) { if ($line->fk_product > 0) { $idp = $obj->find_min_price_product_fournisseur($line->fk_product, $line->qty); if ($idp) { $obj->fetch($idp); if ($obj->delivery_time_days > $nb) { $nb = $obj->delivery_time_days; } } } } if ($nb === 0) { return ''; } else { return $nb . ' ' . $langs->trans('Days'); } }
/** * Return description of module parameters * * @param Translate $langs Output language * @param Societe $soc Third party object * @param int $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ function getToolTip($langs, $soc, $type) { global $conf, $db; $langs->load("admin"); $s = ''; if ($type == -1) { $s .= $langs->trans("Name") . ': <b>' . $this->nom . '</b><br>'; } if ($type == -1) { $s .= $langs->trans("Version") . ': <b>' . $this->getVersion() . '</b><br>'; } //$s.='<br>'; //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; $s .= '<br>'; if ($type == 0 || $type == -1) { $result = $this->get_code($db, $soc, 'customer'); $nextval = $this->code; if (empty($nextval)) { $nextval = $langs->trans("Undefined"); } $s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Customer") . ')' : '') . ': <b>' . $nextval . '</b><br>'; } if ($type == 1 || $type == -1) { $result = $this->get_code($db, $soc, 'supplier'); $nextval = $this->code; if (empty($nextval)) { $nextval = $langs->trans("Undefined"); } $s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Supplier") . ')' : '') . ': <b>' . $nextval . '</b>'; } return $s; }
/** * Show html area for list of subsidiaries * * @param Conf $conf Object conf * @param Translate $langs Object langs * @param DoliDB $db Database handler * @param Societe $object Third party object * @return void */ function show_subsidiaries($conf, $langs, $db, $object) { global $user; global $bc; $i = -1; $sql = "SELECT s.rowid, s.nom as name, s.address, s.zip, s.town, s.code_client, s.canvas"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= " WHERE s.parent = " . $object->id; $sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")"; $sql .= " ORDER BY s.nom"; $result = $db->query($sql); $num = $db->num_rows($result); if ($num) { $socstatic = new Societe($db); print_titre($langs->trans("Subsidiaries")); print "\n" . '<table class="noborder" width="100%">' . "\n"; print '<tr class="liste_titre"><td>' . $langs->trans("Company") . '</td>'; print '<td>' . $langs->trans("Address") . '</td><td>' . $langs->trans("Zip") . '</td>'; print '<td>' . $langs->trans("Town") . '</td><td>' . $langs->trans("CustomerCode") . '</td>'; print "<td> </td>"; print "</tr>"; $i = 0; $var = true; while ($i < $num) { $obj = $db->fetch_object($result); $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td>'; $socstatic->id = $obj->rowid; $socstatic->name = $obj->name; $socstatic->canvas = $obj->canvas; print $socstatic->getNomUrl(1); print '</td>'; print '<td>' . $obj->address . '</td>'; print '<td>' . $obj->zip . '</td>'; print '<td>' . $obj->town . '</td>'; print '<td>' . $obj->code_client . '</td>'; print '<td align="center">'; print '<a href="' . DOL_URL_ROOT . '/societe/soc.php?socid=' . $obj->rowid . '&action=edit">'; print img_edit(); print '</a></td>'; print "</tr>\n"; $i++; } print "\n</table>\n"; } print "<br>\n"; return $i; }
$foundtoprocess = 0; $salerepresentative = dolGetFirstLastname($obj->firstname, $obj->lastname); if (empty($obj->email)) { print "Warning: Sale representative " . $salerepresentative . " has no email. Notice disabled.\n"; } } // Define line content $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($obj->lang) ? $langs->defaultlang : $obj->lang); // By default language of sale representative $outputlangs->load("bills"); $outputlangs->load("main"); $outputlangs->load("contracts"); $outputlangs->load("products"); if (dol_strlen($obj->email)) { $message .= $outputlangs->trans("Contract") . " " . $obj->ref . ": " . $langs->trans("Service") . " " . dol_concatdesc($obj->plabel, $obj->description) . " (" . price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) . ") " . $obj->name . ", " . $outputlangs->trans("DateEndPlannedShort") . " " . dol_print_date($db->jdate($obj->date_fin_validite), 'day') . "\n\n"; dol_syslog("email_expire_services_to_representatives.php: " . $obj->email); $foundtoprocess++; } print "Service to expire " . $obj->ref . ", label " . dol_concatdesc($obj->plabel, $obj->description) . ", due date " . dol_print_date($db->jdate($obj->date_fin_validite), 'day') . " (linked to company " . $obj->name . ", sale representative " . dolGetFirstLastname($obj->firstname, $obj->lastname) . ", email " . $obj->email . "): "; if (dol_strlen($obj->email)) { print "qualified."; } else { print "disqualified (no email)."; } print "\n"; unset($outputlangs); $total += $obj->total_ttc; $i++; } // Si il reste des envois en buffer
/** * Return an example of result returned by getNextValue * * @param Translate $langs Object langs * @param societe $objsoc Object thirdparty * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ function getExample($langs, $objsoc = 0, $type = -1) { if ($type == 0 || $type == -1) { $examplecust = $this->getNextValue($objsoc, 0); if (!$examplecust) { $examplecust = $langs->trans('NotConfigured'); } if ($examplecust == "ErrorBadMask") { $langs->load("errors"); $examplecust = $langs->trans($examplecust); } if ($examplecust == "ErrorCantUseRazIfNoYearInMask") { $langs->load("errors"); $examplecust = $langs->trans($examplecust); } if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") { $langs->load("errors"); $examplecust = $langs->trans($examplecust); } } if ($type == 1 || $type == -1) { $examplesup = $this->getNextValue($objsoc, 1); if (!$examplesup) { $examplesup = $langs->trans('NotConfigured'); } if ($examplesup == "ErrorBadMask") { $langs->load("errors"); $examplesup = $langs->trans($examplesup); } if ($examplesup == "ErrorCantUseRazIfNoYearInMask") { $langs->load("errors"); $examplesup = $langs->trans($examplesup); } if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") { $langs->load("errors"); $examplesup = $langs->trans($examplesup); } } if ($type == 0) { return $examplecust; } if ($type == 1) { return $examplesup; } return $examplecust . '<br>' . $examplesup; }
/** * Update price of next invoice * * @param Translate $langs Translate object * @return bool false if KO, true if OK */ function updatePriceNextInvoice(&$langs) { foreach ($this->tab_next_situation_invoice as $next_invoice) { $is_last = $next_invoice->is_last_in_cycle(); if ($next_invoice->brouillon && $is_last != 1) { $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); return false; } $next_invoice->brouillon = 1; foreach ($next_invoice->lines as $line) { $result = $next_invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); if ($result < 0) { $this->error = $langs->trans('updatePriceNextInvoiceErrorUpdateline', $next_invoice->ref); return false; } } break; // Only the next invoice and not each next invoice } return true; }
/** * Reload menu if dynamic menus, if modified by version * * @param DoliDB $db Database handler * @param Translate $langs Object langs * @param Conf $conf Object conf * @param string $versionto Version target * @return void */ function migrate_reload_menu($db, $langs, $conf, $versionto) { global $conf; dolibarr_install_syslog("upgrade2::migrate_reload_menu"); // Define list of menu handlers to initialize $listofmenuhandler = array(); $versiontoarray = explode('.', $versionto); // Script for VX (X<2.9) -> V2.9 $afterversionarray = explode('.', '2.8.9'); $beforeversionarray = explode('.', '2.9.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers } // Script for VX (X<3.2) -> V3.2 $afterversionarray = explode('.', '3.1.9'); $beforeversionarray = explode('.', '3.2.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers } foreach ($listofmenuhandler as $key => $val) { print '<tr><td colspan="4">'; //print "x".$key; print '<br>'; print '<b>' . $langs->trans('Upgrade') . '</b>: ' . $langs->trans('MenuHandler') . " " . $key . "<br>\n"; // Load sql ini_menu_handler.sql file $dir = DOL_DOCUMENT_ROOT . "/core/menus/"; $file = 'init_menu_' . $key . '.sql'; if (file_exists($dir . $file)) { $result = run_sql($dir . $file, 1, '', 1, $key); } print '</td></tr>'; } }
/** * Return description of module parameters * * @param Translate $langs Output language * @param Product $product Product object * @param int $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ function getToolTip($langs, $product, $type) { global $conf; $langs->load("admin"); $s = ''; if ($type == -1) { $s .= $langs->trans("Name") . ': <b>' . $this->nom . '</b><br>'; } if ($type == -1) { $s .= $langs->trans("Version") . ': <b>' . $this->getVersion() . '</b><br>'; } if ($type == 0) { $s .= $langs->trans("ProductCodeDesc") . '<br>'; } if ($type == 1) { $s .= $langs->trans("ServiceCodeDesc") . '<br>'; } if ($type != -1) { $s .= $langs->trans("ValidityControledByModule") . ': <b>' . $this->getNom($langs) . '</b><br>'; } $s .= '<br>'; $s .= '<u>' . $langs->trans("ThisIsModuleRules") . ':</u><br>'; if ($type == 0) { $s .= $langs->trans("RequiredIfProduct") . ': '; if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) { $s .= '<strike>'; } $s .= yn(!$this->code_null, 1, 2); if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) { $s .= '</strike> ' . yn(1, 1, 2) . ' (' . $langs->trans("ForcedToByAModule", $langs->transnoentities("yes")) . ')'; } $s .= '<br>'; } if ($type == 1) { $s .= $langs->trans("RequiredIfService") . ': '; if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) { $s .= '<strike>'; } $s .= yn(!$this->code_null, 1, 2); if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) { $s .= '</strike> ' . yn(1, 1, 2) . ' (' . $langs->trans("ForcedToByAModule", $langs->transnoentities("yes")) . ')'; } $s .= '<br>'; } if ($type == -1) { $s .= $langs->trans("Required") . ': '; if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) { $s .= '<strike>'; } $s .= yn(!$this->code_null, 1, 2); if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) { $s .= '</strike> ' . yn(1, 1, 2) . ' (' . $langs->trans("ForcedToByAModule", $langs->transnoentities("yes")) . ')'; } $s .= '<br>'; } $s .= $langs->trans("CanBeModifiedIfOk") . ': '; $s .= yn($this->code_modifiable, 1, 2); $s .= '<br>'; $s .= $langs->trans("CanBeModifiedIfKo") . ': ' . yn($this->code_modifiable_invalide, 1, 2) . '<br>'; $s .= $langs->trans("AutomaticCode") . ': ' . yn($this->code_auto, 1, 2) . '<br>'; $s .= '<br>'; if ($type == 0 || $type == -1) { $nextval = $this->getNextValue($product, 0); if (empty($nextval)) { $nextval = $langs->trans("Undefined"); } $s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Product") . ')' : '') . ': <b>' . $nextval . '</b><br>'; } if ($type == 1 || $type == -1) { $nextval = $this->getNextValue($product, 1); if (empty($nextval)) { $nextval = $langs->trans("Undefined"); } $s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Service") . ')' : '') . ': <b>' . $nextval . '</b>'; } return $s; }
/** * Show Dolibarr default login page. * Part of this code is also duplicated into main.inc.php::top_htmlhead * * @param Translate $langs Lang object (must be initialized by a new). * @param Conf $conf Conf object * @param Societe $mysoc Company object * @return void */ function dol_loginfunction($langs, $conf, $mysoc) { global $dolibarr_main_demo, $db; global $smartphone, $hookmanager; // Instantiate hooks of thirdparty module only if not already define $hookmanager->initHooks(array('mainloginpage')); $langs->load("main"); $langs->load("other"); $langs->load("help"); $langs->load("admin"); $main_authentication = $conf->file->main_authentication; $session_name = session_name(); $dol_url_root = DOL_URL_ROOT; $php_self = $_SERVER['PHP_SELF']; $php_self .= $_SERVER["QUERY_STRING"] ? '?' . $_SERVER["QUERY_STRING"] : ''; if (!preg_match('/mainmenu=/', $php_self)) { $php_self .= (preg_match('/\\?/', $php_self) ? '&' : '?') . 'mainmenu=home'; } // Title $title = 'Dolibarr ' . DOL_VERSION; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $title = $conf->global->MAIN_APPLICATION_TITLE; } // Note: $conf->css looks like '/theme/eldy/style.css.php' $conf->css = "/theme/" . (GETPOST('theme') ? GETPOST('theme', 'alpha') : $conf->theme) . "/style.css.php"; //$themepath=dol_buildpath((empty($conf->global->MAIN_FORCETHEMEDIR)?'':$conf->global->MAIN_FORCETHEMEDIR).$conf->css,1); $themepath = dol_buildpath($conf->css, 1); if (!empty($conf->modules_parts['theme'])) { foreach ($conf->modules_parts['theme'] as $reldir) { if (file_exists(dol_buildpath($reldir . $conf->css, 0))) { $themepath = dol_buildpath($reldir . $conf->css, 1); break; } } } $conf_css = $themepath . "?lang=" . $langs->defaultlang; // Select templates if (!empty($conf->modules_parts['tpl'])) { $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl/')); foreach ($dirtpls as $reldir) { $tmp = dol_buildpath($reldir . 'login.tpl.php'); if (file_exists($tmp)) { $template_dir = preg_replace('/login\\.tpl\\.php$/', '', $tmp); break; } } } else { $template_dir = DOL_DOCUMENT_ROOT . "/core/tpl/"; } // Set cookie for timeout management $prefix = dol_getprefix(); $sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix; if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) { setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); } if (GETPOST('urlfrom', 'alpha')) { $_SESSION["urlfrom"] = GETPOST('urlfrom', 'alpha'); } else { unset($_SESSION["urlfrom"]); } if (!GETPOST("username")) { $focus_element = 'username'; } else { $focus_element = 'password'; } $login_background = DOL_URL_ROOT . '/theme/login_background.png'; if (file_exists(DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/img/login_background.png')) { $login_background = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/login_background.png'; } $demologin = ''; $demopassword = ''; if (!empty($dolibarr_main_demo)) { $tab = explode(',', $dolibarr_main_demo); $demologin = $tab[0]; $demopassword = $tab[1]; } // Execute hook getLoginPageOptions // Should be an array with differents options in $hookmanager->resArray $parameters = array('entity' => GETPOST('entity', 'int')); $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks // Login $login = !empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin); $password = $demopassword; // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width = 0; $urllogo = DOL_URL_ROOT . '/theme/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode('thumbs/' . $mysoc->logo_small); } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode($mysoc->logo); $width = 128; } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/img/dolibarr_logo.png')) { $urllogo = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/dolibarr_logo.png'; } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) { $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; } // Security graphical code $captcha = 0; $captcha_refresh = ''; if (function_exists("imagecreatefrompng") && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { $captcha = 1; $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); } // Extra link $forgetpasslink = 0; $helpcenterlink = 0; if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { $forgetpasslink = 1; } if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { $helpcenterlink = 1; } } // Home message $main_home = ''; if (!empty($conf->global->MAIN_HOME)) { $i = 0; while (preg_match('/__\\(([a-zA-Z|@]+)\\)__/i', $conf->global->MAIN_HOME, $reg) && $i < 100) { $tmp = explode('|', $reg[1]); if (!empty($tmp[1])) { $langs->load($tmp[1]); } $conf->global->MAIN_HOME = preg_replace('/__\\(' . preg_quote($reg[1]) . '\\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_HOME); $i++; } $main_home = dol_htmlcleanlastbr($conf->global->MAIN_HOME); } // Google AD $main_google_ad_client = !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT) ? 1 : 0; // Set jquery theme $dol_loginmesg = !empty($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"] : ''; $favicon = dol_buildpath('/theme/' . $conf->theme . '/img/favicon.ico', 1); if (!empty($conf->global->MAIN_FAVICON_URL)) { $favicon = $conf->global->MAIN_FAVICON_URL; } $jquerytheme = 'smoothness'; if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) { $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; } // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_nomousehover $dol_hide_topmenu = GETPOST('dol_hide_topmenu', 'int'); $dol_hide_leftmenu = GETPOST('dol_hide_leftmenu', 'int'); $dol_optimize_smallscreen = GETPOST('dol_optimize_smallscreen', 'int'); $dol_no_mouse_hover = GETPOST('dol_no_mouse_hover', 'int'); $dol_use_jmobile = GETPOST('dol_use_jmobile', 'int'); // Include login page template include $template_dir . 'login.tpl.php'; $_SESSION["dol_loginmesg"] = ''; }
/** * Return array of translated months or selected month. * This replace old function monthArrayOrSelected. * * @param Translate $outputlangs Object langs * @param int $short 1=Return short label * @return array Month string or array if selected < 0 */ function monthArray($outputlangs, $short = 0) { $montharray = array(1 => $outputlangs->trans("January"), 2 => $outputlangs->trans("February"), 3 => $outputlangs->trans("March"), 4 => $outputlangs->trans("April"), 5 => $outputlangs->trans("May"), 6 => $outputlangs->trans("June"), 7 => $outputlangs->trans("July"), 8 => $outputlangs->trans("August"), 9 => $outputlangs->trans("September"), 10 => $outputlangs->trans("October"), 11 => $outputlangs->trans("November"), 12 => $outputlangs->trans("December")); if (!empty($short)) { $montharray = array(1 => $outputlangs->trans("JanuaryMin"), 2 => $outputlangs->trans("FebruaryMin"), 3 => $outputlangs->trans("MarchMin"), 4 => $outputlangs->trans("AprilMin"), 5 => $outputlangs->trans("MayMin"), 6 => $outputlangs->trans("JuneMin"), 7 => $outputlangs->trans("JulyMin"), 8 => $outputlangs->trans("AugustMin"), 9 => $outputlangs->trans("SeptemberMin"), 10 => $outputlangs->trans("OctoberMin"), 11 => $outputlangs->trans("NovemberMin"), 12 => $outputlangs->trans("DecemberMin")); } return $montharray; }
/** * Open output file * * @param string $file File name to generate * @param Translate $outputlangs Output language object * @return int <0 if KO, >=0 if OK */ function open_file($file, $outputlangs) { global $user, $conf, $langs; if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) { $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO } dol_syslog(get_class($this) . "::open_file file=" . $file); $this->file = $file; $ret = 1; $outputlangs->load("exports"); if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) { require_once PHP_WRITEEXCEL_PATH . 'class.writeexcel_workbookbig.inc.php'; require_once PHP_WRITEEXCEL_PATH . 'class.writeexcel_worksheet.inc.php'; require_once PHP_WRITEEXCEL_PATH . 'functions.writeexcel_utility.inc.php'; $this->workbook = new writeexcel_workbookbig($file); $this->workbook->set_tempdir($conf->export->dir_temp); // Set temporary directory $this->workbook->set_sheetname($outputlangs->trans("Sheet")); $this->worksheet =& $this->workbook->addworksheet(); } else { require_once PHPEXCEL_PATH . 'PHPExcel.php'; require_once PHPEXCEL_PATH . 'PHPExcel/Style/Alignment.php'; if ($this->id == 'excel2007') { if (!class_exists('ZipArchive')) { $langs->load("errors"); $this->error = $langs->trans('ErrorPHPNeedModule', 'zip'); return -1; } } $this->workbook = new PHPExcel(); $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs) . ' - Dolibarr ' . DOL_VERSION); //$this->workbook->getProperties()->setLastModifiedBy('Dolibarr '.DOL_VERSION); $this->workbook->getProperties()->setTitle($outputlangs->trans("Export") . ' - ' . $file); $this->workbook->getProperties()->setSubject($outputlangs->trans("Export") . ' - ' . $file); $this->workbook->getProperties()->setDescription($outputlangs->trans("Export") . ' - ' . $file); $this->workbook->setActiveSheetIndex(0); $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet")); $this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16); } return $ret; }
/** * Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remontee des bugs. * On doit appeler cette fonction quand une erreur technique bloquante est rencontree. * Toutefois, il faut essayer de ne l'appeler qu'au sein de pages php, les classes devant * renvoyer leur erreur par l'intermediaire de leur propriete "error". * @param db Database handler * @param error String or array of errors strings to show * @see dol_htmloutput_errors */ function dol_print_error($db = '', $error = '') { global $conf, $langs, $argv; global $dolibarr_main_prod; $out = ''; $syslog = ''; // Si erreur intervenue avant chargement langue if (!$langs) { require_once DOL_DOCUMENT_ROOT . "/core/class/translate.class.php"; $langs = new Translate("", $conf); $langs->load("main"); } $langs->load("main"); $langs->load("errors"); if ($_SERVER['DOCUMENT_ROOT']) { $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n"; if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { $out .= "You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.<br>\n"; } $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n"; $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n"; $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n"; if (isset($conf->global->MAIN_FEATURES_LEVEL)) { $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n"; } if (function_exists("phpversion")) { $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n"; //phpinfo(); // This is to show location of php.ini file } $out .= "<b>" . $langs->trans("Server") . ":</b> " . $_SERVER["SERVER_SOFTWARE"] . "<br>\n"; $out .= "<br>\n"; $out .= "<b>" . $langs->trans("RequestedUrl") . ":</b> " . $_SERVER["REQUEST_URI"] . "<br>\n"; $out .= "<b>" . $langs->trans("Referer") . ":</b> " . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '') . "<br>\n"; $out .= "<b>" . $langs->trans("MenuManager") . ":</b> " . $conf->top_menu . "<br>\n"; $out .= "<br>\n"; $syslog .= "url=" . $_SERVER["REQUEST_URI"]; $syslog .= ", query_string=" . $_SERVER["QUERY_STRING"]; } else { $out .= '> ' . $langs->transnoentities("ErrorInternalErrorDetected") . ":\n" . $argv[0] . "\n"; $syslog .= "pid=" . getmypid(); } if (is_object($db)) { if ($_SERVER['DOCUMENT_ROOT']) { $out .= "<b>" . $langs->trans("DatabaseTypeManager") . ":</b> " . $db->type . "<br>\n"; $out .= "<b>" . $langs->trans("RequestLastAccessInError") . ":</b> " . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->trans("ErrorNoRequestInError")) . "<br>\n"; $out .= "<b>" . $langs->trans("ReturnCodeLastAccessInError") . ":</b> " . ($db->lasterrno() ? $db->lasterrno() : $langs->trans("ErrorNoRequestInError")) . "<br>\n"; $out .= "<b>" . $langs->trans("InformationLastAccessInError") . ":</b> " . ($db->lasterror() ? $db->lasterror() : $langs->trans("ErrorNoRequestInError")) . "<br>\n"; $out .= "<br>\n"; } else { $out .= '> ' . $langs->transnoentities("DatabaseTypeManager") . ":\n" . $db->type . "\n"; $out .= '> ' . $langs->transnoentities("RequestLastAccessInError") . ":\n" . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->trans("ErrorNoRequestInError")) . "\n"; $out .= '> ' . $langs->transnoentities("ReturnCodeLastAccessInError") . ":\n" . ($db->lasterrno() ? $db->lasterrno() : $langs->trans("ErrorNoRequestInError")) . "\n"; $out .= '> ' . $langs->transnoentities("InformationLastAccessInError") . ":\n" . ($db->lasterror() ? $db->lasterror() : $langs->trans("ErrorNoRequestInError")) . "\n"; } $syslog .= ", sql=" . $db->lastquery(); $syslog .= ", db_error=" . $db->lasterror(); } if ($error) { $langs->load("errors"); if (is_array($error)) { $errors = $error; } else { $errors = array($error); } foreach ($errors as $msg) { $msg = $langs->trans($msg); if ($_SERVER['DOCUMENT_ROOT']) { $out .= "<b>" . $langs->trans("Message") . ":</b> " . $msg . "<br>\n"; } else { $out .= '> ' . $langs->transnoentities("Message") . ":\n" . $msg . "\n"; } $syslog .= ", msg=" . $msg; } } if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_call_file')) { xdebug_print_function_stack(); $out .= '<b>XDebug informations:</b>' . "<br>\n"; $out .= 'File: ' . xdebug_call_file() . "<br>\n"; $out .= 'Line: ' . xdebug_call_line() . "<br>\n"; $out .= 'Function: ' . xdebug_call_function() . "<br>\n"; $out .= "<br>\n"; } if (empty($dolibarr_main_prod)) { print $out; } else { define("MAIN_CORE_ERROR", 1); } //else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.'; dol_syslog("Error " . $syslog, LOG_ERR); }
/** * Send email * * @param string $mode Mode (test | confirm) * @param string $oldemail Old email * @param string $message Message to send * @param string $total Total amount of unpayed invoices * @param string $userlang Code lang to use for email output. * @param string $oldsalerepresentative Old sale representative * @return int <0 if KO, >0 if OK */ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldsalerepresentative) { global $conf, $langs; if (getenv('DOL_FORCE_EMAIL_TO')) { $oldemail = getenv('DOL_FORCE_EMAIL_TO'); } $newlangs = new Translate('', $conf); $newlangs->setDefaultLang(empty($userlang) ? empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT : $userlang); $newlangs->load("main"); $newlangs->load("bills"); $subject = empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT; $sendto = $oldemail; $from = $conf->global->MAIN_MAIL_EMAIL_FROM; $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $msgishtml = -1; print "- Send email for " . $oldsalerepresentative . " (" . $oldemail . "), total: " . $total . "\n"; dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to " . $oldemail); $usehtml = 0; if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) { $usehtml += 1; } if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER)) { $usehtml += 1; } $allmessage = ''; if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER)) { $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER; } else { $allmessage .= $newlangs->transnoentities("ListOfYourUnpaidInvoices") . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n"); $allmessage .= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices") . ($usehtml ? "<br>\n" : "\n"); } $allmessage .= $message . ($usehtml ? "<br>\n" : "\n"); $allmessage .= $langs->trans("Total") . " = " . price($total, 0, $newlangs, 0, 0, -1, $conf->currency) . ($usehtml ? "<br>\n" : "\n"); if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) { $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER; if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) { $usehtml += 1; } } $mail = new CMailFile($subject, $sendto, $from, $allmessage, array(), array(), array(), '', '', 0, $msgishtml); $mail->errors_to = $errorsto; // Send or not email if ($mode == 'confirm') { $result = $mail->sendfile(); if (!$result) { print "Error sending email " . $mail->error . "\n"; dol_syslog("Error sending email " . $mail->error . "\n"); } } else { print "No email sent (test mode)\n"; dol_syslog("No email sent (test mode)"); $mail->dump_mail(); $result = 1; } if ($result) { return 1; } else { return -1; } }
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; $datenow = dol_now(); $datefirst = dol_stringtotime($_POST["dst_first"]); $datesecond = dol_stringtotime($_POST["dst_second"]); if ($datenow >= $datefirst && $datenow < $datesecond) { $dol_dst = 1; } } //print $datefirst.'-'.$datesecond.'-'.$datenow.'-'.$dol_tz.'-'.$dol_tzstring.'-'.$dol_dst; exit; } if (!$login) { dol_syslog('Bad password, connexion refused', LOG_DEBUG); $langs->load('main'); $langs->load('errors'); // Bad password. No authmode has found a good password. $user->trigger_mesg = $langs->trans("ErrorBadLoginPassword") . ' - login='******'/core/class/interfaces.class.php'; $interface = new Interfaces($db); $result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf, GETPOST("username", "alpha", 2)); if ($result < 0) { $error++; } // End Call of triggers // Hooks on failed login $action = '';
/** * Return description of a module * * @param Translate $langs Object language * @return string Description */ function info($langs) { global $conf, $langs; $langs->load("companies"); $langs->load("errors"); $form = new Form($db); $texte = $this->description . ".<br>\n"; $texte .= '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; $texte .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; $texte .= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">'; $texte .= '<table class="nobordernopadding" width="100%">'; // List of directories area $texte .= '<tr><td>'; $texttitle = $langs->trans("ListOfDirectories"); $listofdir = explode(',', preg_replace('/[\\r\\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); $listoffiles = array(); 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)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); } else { $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\\.odt'); if (count($tmpfiles)) { $listoffiles = array_merge($listoffiles, $tmpfiles); } } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys $texthelp .= '<br>' . $langs->trans("FollowingSubstitutionKeysCanBeUsed") . '<br>'; $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); $texte .= '<table><tr><td>'; $texte .= '<textarea class="flat" cols="60" name="value1">'; $texte .= $conf->global->COMPANY_ADDON_PDF_ODT_PATH; $texte .= '</textarea>'; $texte .= '</td>'; $texte .= '<td align="center"> '; $texte .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button">'; $texte .= '</td>'; $texte .= '</tr>'; $texte .= '</table>'; // Scan directories if (count($listofdir)) { $texte .= $langs->trans("NumberOfModelFilesFound") . ': <b>' . count($listoffiles) . '</b>'; } $texte .= '</td>'; $texte .= '<td valign="top" rowspan="2">'; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); $texte .= '</td>'; $texte .= '</tr>'; /*$texte.= '<tr><td align="center">'; $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; $texte.= '</td>'; $texte.= '</tr>';*/ $texte .= '</table>'; $texte .= '</form>'; return $texte; }
/** * Return an example of result returned by getNextValue * * @param Translate $langs Object langs * @param product $objproduct Object product * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ function getExample($langs, $objproduct = 0, $type = -1) { if ($type == 0 || $type == -1) { $exampleproduct = $this->getNextValue($objproduct, 0); if (!$exampleproduct) { $exampleproduct = $langs->trans('NotConfigured'); } if ($exampleproduct == "ErrorBadMask") { $langs->load("errors"); $exampleproduct = $langs->trans($exampleproduct); } } if ($type == 1 || $type == -1) { $exampleservice = $this->getNextValue($objproduct, 1); if (!$exampleservice) { $exampleservice = $langs->trans('NotConfigured'); } if ($exampleservice == "ErrorBadMask") { $langs->load("errors"); $exampleservice = $langs->trans($exampleservice); } } if ($type == 0) { return $exampleproduct; } if ($type == 1) { return $exampleservice; } return $exampleproduct . '<br>' . $exampleservice; }
/** * Show a message to say access is forbidden and stop program * Calling this function terminate execution of PHP. * * @param string $message Force error message * @param int $printheader Show header before * @param int $printfooter Show footer after * @param int $showonlymessage Show only message parameter. Otherwise add more information. * @return void */ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0) { global $conf, $db, $user, $langs; if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php'; $langs = new Translate('', $conf); } $langs->load("errors"); if ($printheader) { if (function_exists("llxHeader")) { llxHeader(''); } else { if (function_exists("llxHeaderVierge")) { llxHeaderVierge(''); } } } print '<div class="error">'; if (!$message) { print $langs->trans("ErrorForbidden"); } else { print $message; } print '</div>'; print '<br>'; if (empty($showonlymessage)) { if ($user->login) { print $langs->trans("CurrentLogin") . ': <font class="error">' . $user->login . '</font><br>'; print $langs->trans("ErrorForbidden2", $langs->trans("Home"), $langs->trans("Users")); } else { print $langs->trans("ErrorForbidden3"); } } if ($printfooter && function_exists("llxFooter")) { llxFooter(); } exit(0); }
function translation($lang, $str) { $t = new Translate($lang); $res = $t->trans($str); return $res; }
/** * Return an example of result returned by getNextValue * * @param Translate $langs Object langs * @param Product $objproduct Object product * @return string Return string example */ function getExample($langs, $objproduct = 0) { $examplebarcode = $this->getNextValue($objproduct, 0); if (!$examplebarcode) { $examplebarcode = $langs->trans('NotConfigured'); } if ($examplebarcode == "ErrorBadMask") { $langs->load("errors"); $examplebarcode = $langs->trans($examplebarcode); } return $examplebarcode; }
/** * Return description of module * * @param Translate $langs Object langs * @return string Description of module */ function info($langs) { return $langs->trans("ModuleCompanyCode" . $this->name); }
/** Return description of module * * @param Translate $langs Object langs * @return string Description of module */ function info($langs) { return $langs->trans("MonkeyNumRefModelDesc", $this->prefixcustomer, $this->prefixsupplier); }
/** * Function called when a Dolibarrr business event is done. * All functions "run_trigger" are triggered if file * is inside directory core/triggers * * @param string $action Event action code * @param Object $object Object * @param User $user Object user * @param Translate $langs Object langs * @param conf $conf Object conf * @return int <0 if KO, 0 if no triggered ran, >0 if OK */ public function run_trigger($action, $object, $user, $langs, $conf) { if ($action == 'SHIPPING_VALIDATE') { // Classer délivrée la commande si totalement expédiée if ($conf->global->SHIPPABLEORDER_CLOSE_ORDER) { dol_include_once('/commande/class/commande.class.php'); dol_include_once('/shippableorder/class/shippableorder.class.php'); $object->fetchObjectLinked(0, 'commande'); if (!empty($object->linkedObjects['commande'])) { $commande = array_pop($object->linkedObjects['commande']); $orderShippable = new ShippableOrder($this->db); $orderShippable->isOrderShippable($commande->id); if ($orderShippable->nbProduct == 0) { $commande->cloture($user); setEventMessage($langs->trans('OrderClosed', $commande->ref)); } } } dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } return 0; }