本文整理汇总了PHP中Translate::setDefaultLang方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::setDefaultLang方法的具体用法?PHP Translate::setDefaultLang怎么用?PHP Translate::setDefaultLang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translate
的用法示例。
在下文中一共展示了Translate::setDefaultLang方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFactureBuild
/**
* testFactureBuild
*
* @return int
*/
public function testFactureBuild()
{
global $conf, $user, $langs, $db;
$conf = $this->savconf;
$user = $this->savuser;
$langs = $this->savlangs;
$db = $this->savdb;
$conf->facture->dir_output .= '/temp';
$localobjectcom = new Commande($this->savdb);
$localobjectcom->initAsSpecimen();
$localobject = new Facture($this->savdb);
$localobject->createFromOrder($localobjectcom);
$localobject->date_lim_reglement = dol_now() + 3600 * 24 * 30;
// Crabe (english)
$localobject->modelpdf = 'crabe';
$result = $localobject->generateDocument($localobject->modelpdf, $langs);
$this->assertLessThan($result, 0);
print __METHOD__ . " result=" . $result . "\n";
// Crabe (japanese)
$newlangs1 = new Translate("", $conf);
$newlangs1->setDefaultLang('ja_JP');
$localobject->modelpdf = 'crabe';
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs1);
$this->assertLessThan($result, 0);
print __METHOD__ . " result=" . $result . "\n";
// Crabe (saudiarabia)
$newlangs2a = new Translate("", $conf);
$newlangs2a->setDefaultLang('sa_SA');
$localobject->modelpdf = 'crabe';
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs2a);
$this->assertLessThan($result, 0);
print __METHOD__ . " result=" . $result . "\n";
// Crabe (english_saudiarabia)
$newlangs2b = new Translate("", $conf);
$newlangs2b->setDefaultLang('en_SA');
$localobject->modelpdf = 'crabe';
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs2b);
$this->assertLessThan($result, 0);
print __METHOD__ . " result=" . $result . "\n";
// Crabe (greek)
$newlangs3 = new Translate("", $conf);
$newlangs3->setDefaultLang('el_GR');
$localobject->modelpdf = 'crabe';
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs3);
$this->assertLessThan($result, 0);
print __METHOD__ . " result=" . $result . "\n";
// Crabe (chinese)
$newlangs4 = new Translate("", $conf);
$newlangs4->setDefaultLang('zh_CN');
$localobject->modelpdf = 'crabe';
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs4);
$this->assertLessThan($result, 0);
print __METHOD__ . " result=" . $result . "\n";
// Crabe (russian)
$newlangs5 = new Translate("", $conf);
$newlangs5->setDefaultLang('ru_RU');
$localobject->modelpdf = 'crabe';
$result = $localobject->generateDocument($localobject->modelpdf, $newlangs5);
$this->assertLessThan($result, 0);
print __METHOD__ . " result=" . $result . "\n";
return 0;
}
示例2: testDolPrintDateTzFrance
/**
* testDolPrintDateTzFrance
* Same than official testDolPrintDate but with parameter tzoutput that is false='tzserver'.
* This test works only onto a server using TZ+1 Europe/Paris.
*
* You can use http://www.epochconverter.com/ to generate more tests.
*
* @return void
*/
public function testDolPrintDateTzFrance()
{
global $conf, $user, $langs, $db;
$conf = $this->savconf;
$user = $this->savuser;
$langs = $this->savlangs;
$db = $this->savdb;
// Check %Y-%m-%d %H:%M:%S format
$result = dol_print_date(0, '%Y-%m-%d %H:%M:%S', false);
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('1970-01-01 01:00:00', $result);
// Check %Y-%m-%d %H:%M:%S format
$result = dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', false);
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('2500-01-01 01:00:00', $result);
// Check %Y-%m-%d %H:%M:%S format
$result = dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', false);
// http://www.epochconverter.com/
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('1912-01-01 01:00:00', $result);
// dol_print_date use a timezone, not epoch converter as it did not exists this year
// Specific cas during war
// 1940, no timezone
$result = dol_print_date(-946771200, '%Y-%m-%d %H:%M:%S', false);
// http://www.epochconverter.com/
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('1940-01-01 01:00:00', $result);
// dol_print_date use a modern timezone, not epoch converter as it did not exists this year
// 1941, timezone is added by germany to +2 (same for 1942)
$result = dol_print_date(-915148800, '%Y-%m-%d %H:%M:%S', false);
// http://www.epochconverter.com/
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('1941-01-01 01:00:00', $result);
// dol_print_date use a modern timezone, epoch converter use historic timezone
// 1943, timezone is +1
$result = dol_print_date(-852076800, '%Y-%m-%d %H:%M:%S', false);
// http://www.epochconverter.com/
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('1943-01-01 01:00:00', $result);
// test with negative timezone
$result = dol_print_date(-1, '%Y-%m-%d %H:%M:%S', false);
// http://www.epochconverter.com/
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('1970-01-01 00:59:59', $result);
// Check dayhour format for fr_FR
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang('fr_FR');
$outputlangs->load("main");
$result = dol_print_date(0 + 24 * 3600, 'dayhour', false, $outputlangs);
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('02/01/1970 01:00', $result);
// Check day format for en_US
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang('en_US');
$outputlangs->load("main");
$result = dol_print_date(0 + 24 * 3600, 'day', false, $outputlangs);
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('01/02/1970', $result);
// Check %a and %b format for en_US
$result = dol_print_date(0, '%a %b', false, $outputlangs);
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals('Thu Jan', $result);
return $result;
}
示例3: conf
// Off mode (recommended, you just do $db->escape when an insert / update.
function stripslashes_deep($value)
{
return is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
}
$_GET = array_map('stripslashes_deep', $_GET);
$_POST = array_map('stripslashes_deep', $_POST);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
@set_magic_quotes_runtime(0);
}
}
// Defini objet langs
$langs = new Translate('..', $conf);
if (GETPOST('lang')) {
$langs->setDefaultLang(GETPOST('lang'));
} else {
$langs->setDefaultLang('auto');
}
$bc[false] = ' class="bg1"';
$bc[true] = ' class="bg2"';
/**
* Load conf file (file must exists)
*
* @param string $dolibarr_main_document_root Root directory of Dolibarr bin files
* @return int <0 if KO, >0 if OK
*/
function conf($dolibarr_main_document_root)
{
global $conf;
global $dolibarr_main_db_type;
示例4: cloture
/**
* Close the commercial proposal
*
* @param User $user Object user that close
* @param int $statut Statut
* @param string $note Comment
* @return int <0 if KO, >0 if OK
*/
function cloture($user, $statut, $note)
{
global $langs, $conf;
$this->statut = $statut;
$error = 0;
$now = dol_now();
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "propal";
$sql .= " SET fk_statut = " . $statut . ", note_private = '" . $this->db->escape($note) . "', date_cloture='" . $this->db->idate($now) . "', fk_user_cloture=" . $user->id;
$sql .= " WHERE rowid = " . $this->id;
$resql = $this->db->query($sql);
if ($resql) {
$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->modelpdf;
$trigger_name = 'PROPAL_CLOSE_REFUSED';
if ($statut == 2) {
$trigger_name = 'PROPAL_CLOSE_SIGNED';
$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->modelpdf;
// The connected company is classified as a client
$soc = new Societe($this->db);
$soc->id = $this->socid;
$result = $soc->set_as_client();
if ($result < 0) {
$this->error = $this->db->error();
$this->db->rollback();
return -2;
}
}
if ($statut == 4) {
$trigger_name = 'PROPAL_CLASSIFY_BILLED';
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
// Define output language
$outputlangs = $langs;
if (!empty($conf->global->MAIN_MULTILANGS)) {
$outputlangs = new Translate("", $conf);
$newlang = GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang;
$outputlangs->setDefaultLang($newlang);
}
//$ret=$object->fetch($id); // Reload to get new records
$this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
// Call trigger
$result = $this->call_trigger($trigger_name, $user);
if ($result < 0) {
$error++;
}
// End call triggers
if (!$error) {
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return -1;
}
} else {
$this->error = $this->db->error();
$this->db->rollback();
return -1;
}
}
示例5: doActions
//.........这里部分代码省略.........
$contact->zip = $this->object->zip;
$contact->town = $this->object->town;
$contact->country_id = $this->object->country_id;
$contact->socid = $this->object->id;
// fk_soc
$contact->status = 1;
$contact->email = $this->object->email;
$contact->priv = 0;
$result = $contact->create($user);
}
} else {
$this->errors = $this->object->errors;
}
if ($result >= 0) {
$this->db->commit();
if ($this->object->client == 1) {
header("Location: " . DOL_URL_ROOT . "/comm/fiche.php?socid=" . $this->object->id);
return;
} else {
if ($this->object->fournisseur == 1) {
header("Location: " . DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $this->object->id);
return;
} else {
header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
return;
}
}
exit;
} else {
$this->db->rollback();
$this->errors = $this->object->errors;
$action = 'create';
}
}
if ($action == 'update') {
if ($_POST["cancel"]) {
header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
exit;
}
$oldsoccanvas = dol_clone($this->object);
// To avoid setting code if third party is not concerned. But if it had values, we keep them.
if (empty($this->object->client) && empty($oldsoccanvas->code_client)) {
$this->object->code_client = '';
}
if (empty($this->object->fournisseur) && empty($oldsoccanvas->code_fournisseur)) {
$this->object->code_fournisseur = '';
}
$result = $this->object->update($this->object->id, $user, 1, $oldsoccanvas->codeclient_modifiable(), $oldsoccanvas->codefournisseur_modifiable());
if ($result >= 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?socid=" . $this->object->id);
exit;
} else {
$reload = 0;
$this->errors = $this->object->errors;
$action = "edit";
}
}
}
}
if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes') {
$result = $this->object->delete($this->object->id);
if ($result >= 0) {
header("Location: " . DOL_URL_ROOT . "/societe/societe.php?delsoc=" . $this->object->nom . "");
exit;
} else {
$reload = 0;
$this->errors = $this->object->errors;
$action = '';
}
}
/*
* Generate document
*/
if ($action == 'builddoc') {
if (is_numeric(GETPOST('model'))) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model"));
} else {
require_once DOL_DOCUMENT_ROOT . '/core/modules/societe/modules_societe.class.php';
$this->object->fetch_thirdparty();
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) {
$newlang = GETPOST('lang_id');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $this->object->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$result = thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model', 'alpha'), $outputlangs);
if ($result <= 0) {
dol_print_error($this->db, $result);
exit;
}
}
}
}
示例6: Translate
// If error, we will put error message in session under the name dol_loginmesg
$goontestloop = false;
if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) {
$goontestloop = true;
}
if ($dolibarr_main_authentication == 'forceuser' && !empty($dolibarr_auto_user)) {
$goontestloop = true;
}
if (GETPOST("username", "alpha", 2) || !empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode', 'alpha', 1)) {
$goontestloop = true;
}
if (!is_object($langs)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php';
$langs = new Translate("", $conf);
$langcode = GETPOST('lang') ? GETPOST('lang', 'alpha', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
$langs->setDefaultLang($langcode);
}
if ($test && $goontestloop) {
$login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode);
if ($login) {
$dol_authmode = $conf->authmode;
// This properties is defined only when logged, to say what mode was successfully used
$dol_tz = $_POST["tz"];
$dol_tz_string = $_POST["tz_string"];
$dol_tz_string = preg_replace('/\\s*\\(.+\\)$/', '', $dol_tz_string);
$dol_tz_string = preg_replace('/,/', '/', $dol_tz_string);
$dol_tz_string = preg_replace('/\\s/', '_', $dol_tz_string);
$dol_dst = 0;
if (isset($_POST["dst_first"]) && isset($_POST["dst_second"])) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
$datenow = dol_now();
示例7: conf
// Off mode (recommended, you just do $db->escape when an insert / update.
function stripslashes_deep($value)
{
return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
}
$_GET = array_map('stripslashes_deep', $_GET);
$_POST = array_map('stripslashes_deep', $_POST);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
@set_magic_quotes_runtime(0);
}
}
// Defini objet langs
$langs = new Translate('..',$conf);
if (GETPOST('lang')) $langs->setDefaultLang(GETPOST('lang'));
else $langs->setDefaultLang('auto');
$bc[false]=' class="bg1"';
$bc[true]=' class="bg2"';
/**
* Load conf file (file must exists)
*
* @param string $dolibarr_main_document_root Root directory of Dolibarr bin files
* @return int <0 if KO, >0 if OK
*/
function conf($dolibarr_main_document_root)
{
global $conf;
示例8: doActions
//.........这里部分代码省略.........
{
$this->db->rollback();
$this->errors=$this->object->errors;
$_GET["action"]='create';
}
}
if ($_POST["action"] == 'update')
{
if ($_POST["cancel"])
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
exit;
}
$oldsoccanvas = new Canvas($this->db);
$oldsoccanvas->getCanvas('thirdparty','card',$this->object->canvas);
$result=$oldsoccanvas->control->object->fetch($socid);
// To avoid setting code if third party is not concerned. But if it had values, we keep them.
if (empty($this->object->client) && empty($oldsoccanvas->control->object->code_client)) $this->object->code_client='';
if (empty($this->object->fournisseur)&& empty($oldsoccanvas->control->object->code_fournisseur)) $this->object->code_fournisseur=''; //var_dump($soccanvas);exit;
$result = $this->object->update($socid,$user,1,$oldsoccanvas->control->object->codeclient_modifiable(),$oldsoccanvas->control->object->codefournisseur_modifiable());
if ($result >= 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
exit;
}
else
{
$this->object->id = $socid;
$reload = 0;
$this->errors = $this->object->errors;
$_GET["action"]="edit";
}
}
}
}
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes')
{
$this->object->fetch($socid);
$result = $this->object->delete($socid);
if ($result >= 0)
{
Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$this->object->nom."");
exit;
}
else
{
$reload = 0;
$this->errors=$this->object->errors;
$_GET["action"]='';
}
}
/*
* Generate document
*/
if (GETPOST('action') == 'builddoc') // En get ou en post
{
if (is_numeric(GETPOST('model')))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
}
else
{
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php');
$this->object->fetch($socid);
$this->object->fetch_thirdparty();
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id') ) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$this->object->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model'), $outputlangs);
if ($result <= 0)
{
dol_print_error($this->db,$result);
exit;
}
else
{
Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$this->object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
exit;
}
}
}
}
示例9: Form
/**
* Get the form to input an email
* this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
* this->param: Contains more parameteres like email templates info
*
* @param string $addfileaction Name of action when posting file attachments
* @param string $removefileaction Name of action when removing file attachments
* @return string Form to show
*/
function get_form($addfileaction = 'addfile', $removefileaction = 'removefile')
{
global $conf, $langs, $user, $hookmanager, $form;
if (!is_object($form)) {
$form = new Form($this->db);
}
$langs->load("other");
$langs->load("mails");
$hookmanager->initHooks(array('formmail'));
$parameters = array('addfileaction' => $addfileaction, 'removefileaction' => $removefileaction);
$reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this);
if (!empty($reshook)) {
return $hookmanager->resPrint;
} else {
$out = '';
// Define list of attached files
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
if (!empty($_SESSION["listofpaths"])) {
$listofpaths = explode(';', $_SESSION["listofpaths"]);
}
if (!empty($_SESSION["listofnames"])) {
$listofnames = explode(';', $_SESSION["listofnames"]);
}
if (!empty($_SESSION["listofmimes"])) {
$listofmimes = explode(';', $_SESSION["listofmimes"]);
}
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $this->param['langsmodels'];
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('other');
}
// Get message template
$model_id = 0;
if (array_key_exists('models_id', $this->param)) {
$model_id = $this->param["models_id"];
}
$arraydefaultmessage = $this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
//var_dump($arraydefaultmessage);
$out .= "\n<!-- Begin form mail -->\n";
if ($this->withform == 1) {
$out .= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '#formmail">' . "\n";
$out .= '<input style="display:none" type="submit" id="sendmail" name="sendmail">';
$out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />';
$out .= '<input type="hidden" name="trackid" value="' . $this->trackid . '" />';
$out .= '<a id="formmail" name="formmail"></a>';
}
foreach ($this->param as $key => $value) {
$out .= '<input type="hidden" id="' . $key . '" name="' . $key . '" value="' . $value . '" />' . "\n";
}
$result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
if ($result < 0) {
setEventMessage($this->error, 'errors');
}
$modelmail_array = array();
foreach ($this->lines_model as $line) {
$modelmail_array[$line->id] = $line->label;
}
// Zone to select its email template
if (count($modelmail_array) > 0) {
$out .= '<div style="padding: 3px 0 3px 0">' . "\n";
$out .= $langs->trans('SelectMailModel') . ': ' . $this->selectarray('modelmailselected', $modelmail_array, 0, 1);
if ($user->admin) {
$out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
$out .= ' ';
$out .= '<input class="button" type="submit" value="' . $langs->trans('Valid') . '" name="modelselected" id="modelselected">';
$out .= ' ';
$out .= '</div>';
}
$out .= '<table class="border" width="100%">' . "\n";
// Substitution array
if (!empty($this->withsubstit)) {
$out .= '<tr><td colspan="2">';
$help = "";
foreach ($this->substit as $key => $val) {
$help .= $key . ' -> ' . $langs->trans($val) . '<br>';
}
$out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help);
$out .= "</td></tr>\n";
}
// From
if (!empty($this->withfrom)) {
if (!empty($this->withfromreadonly)) {
//.........这里部分代码省略.........
示例10: envoi_mail
/**
* Send email
*
* @param string $mode Mode (test | confirm)
* @param string $oldemail Target 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 $oldtarget Target name
* @return int <0 if KO, >0 if OK
*/
function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget)
{
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_CUSTOMERS_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT;
$sendto = $oldemail;
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
$msgishtml = -1;
print "- Send email to '" . $oldtarget . "' (" . $oldemail . "), total: " . $total . "\n";
dol_syslog("email_unpaid_invoices_to_customers.php: send mail to " . $oldemail);
$usehtml = 0;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) {
$usehtml += 1;
}
if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) {
$usehtml += 1;
}
$allmessage = '';
if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) {
$allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER;
} else {
$allmessage .= "Dear customer" . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
$allmessage .= "Please, find a summary of the bills with pending payments from you." . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
$allmessage .= "Note: This list contains only unpaid invoices." . ($usehtml ? "<br>\n" : "\n");
}
$allmessage .= $message . ($usehtml ? "<br>\n" : "\n");
$allmessage .= $langs->trans("Total") . " = " . price($total, 0, $userlang, 0, 0, -1, $conf->currency) . ($usehtml ? "<br>\n" : "\n");
if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) {
$allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_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;
}
unset($newlangs);
if ($result) {
return 1;
} else {
return -1;
}
}
示例11: testLang
/**
* 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;
}
示例12: envoi_mail
/**
* Send email
*
* @param string $mode Mode (test | confirm)
* @param string $oldemail Target 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 $oldtarget Target name
* @param int $duration_value duration value
* @return int <0 if KO, >0 if OK
*/
function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget, $duration_value)
{
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("contracts");
if ($duration_value) {
if ($duration_value > 0) {
$title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value);
} else {
$title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value);
}
} else {
$title = $newlangs->transnoentities("ListOfServicesToExpire");
}
$subject = empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT) ? $title : $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT;
$sendto = $oldemail;
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
$msgishtml = -1;
print "- Send email to '" . $oldtarget . "' (" . $oldemail . "), total: " . $total . "\n";
dol_syslog("email_expire_services_to_customers.php: send mail to " . $oldemail);
$usehtml = 0;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) {
$usehtml += 1;
}
if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER)) {
$usehtml += 1;
}
$allmessage = '';
if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER)) {
$allmessage .= $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_HEADER;
} else {
$allmessage .= "Dear customer" . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
$allmessage .= "Please, find a summary of the services contracted by you that are about to expire." . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n");
}
$allmessage .= $message . ($usehtml ? "<br>\n" : "\n");
//$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");
if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) {
$allmessage .= $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_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;
}
unset($newlangs);
if ($result) {
return 1;
} else {
return -1;
}
}
示例13: chmod
if ($action == 1) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else {
if ($action == 2) {
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
}
return $output;
}
if (file_exists('conf/conf.php')) {
include 'conf/conf.php';
if (!empty($_GET['lang'])) {
$conf->user->lang = $_GET['lang'];
}
$langs->setDefaultLang($conf->user->lang);
$langs->load("main");
} else {
chmod('conf', 755);
$capfile = fopen('conf/conf.php', "w");
fwrite($capfile, "\n\t\t<?php\n\t\t\$" . "conf->lang['en-GB'] = 'english';\n\t\t\$" . "conf->lang['ca'] = 'català';\n\t\t\$" . "conf->lang['cs'] = 'ceština';\n\t\t\$" . "conf->lang['da-DK'] = 'dansk';\n\t\t\$" . "conf->lang['de-DE'] = 'deutsch';\n\t\t\$" . "conf->lang['es-ES'] = 'español';\n\t\t\$" . "conf->lang['et'] = 'eesti';\n\t\t\$" . "conf->lang['eu'] = 'euskera';\n\t\t\$" . "conf->lang['fr-FR'] = 'français';\n\t\t\$" . "conf->lang['gl'] = 'galego';\n\t\t\$" . "conf->lang['hr-HR'] = 'hrvatski';\n\t\t\$" . "conf->lang['is'] = 'íslenska';\n\t\t\$" . "conf->lang['it-IT'] = 'italiano';\n\t\t\$" . "conf->lang['lt'] = 'lietuviu';\n\t\t\$" . "conf->lang['lv'] = 'latviešu';\n\t\t\$" . "conf->lang['hu-HU'] = 'magyar';\n\t\t\$" . "conf->lang['mt'] = 'malti';\n\t\t\$" . "conf->lang['nl-NL'] = 'nederlands';\n\t\t\$" . "conf->lang['no'] = 'norsk';\n\t\t\$" . "conf->lang['pl'] = 'polski';\n\t\t\$" . "conf->lang['pt-PT'] = 'português';\n\t\t\$" . "conf->lang['ro'] = 'româna';\n\t\t\$" . "conf->lang['sr'] = 'српски';\n\t\t\$" . "conf->lang['sl'] = 'slovenšcina';\n\t\t\$" . "conf->lang['sk'] = 'slovencina';\n\t\t\$" . "conf->lang['fi-FI'] = 'suomi';\n\t\t\$" . "conf->lang['sv-SE'] = 'svenska';\n\t\t\$" . "conf->lang['el-GR'] = 'Ελληνικά';\n\t\t\$" . "conf->lang['bg'] = 'bulgarian';\n\t\t\$" . "conf->lang['mk'] = 'македонски';\n\t\t\$" . "conf->lang['name'] = '';\n\t\t\n\t\t\$" . "conf->select->lang['en-GB'] = 1;\n\t\t\$" . "conf->select->lang['ca'] = 0;\n\t\t\$" . "conf->select->lang['cs'] = 0;\n\t\t\$" . "conf->select->lang['da-DK'] = 0;\n\t\t\$" . "conf->select->lang['de-DE'] = 1;\n\t\t\$" . "conf->select->lang['es-ES'] = 0;\n\t\t\$" . "conf->select->lang['et'] = 0;\n\t\t\$" . "conf->select->lang['eu'] = 0;\n\t\t\$" . "conf->select->lang['fr-FR'] = 0;\n\t\t\$" . "conf->select->lang['gl'] = 0;\n\t\t\$" . "conf->select->lang['hr-HR'] = 0;\n\t\t\$" . "conf->select->lang['is'] = 0;\n\t\t\$" . "conf->select->lang['it-IT'] = 0;\n\t\t\$" . "conf->select->lang['lt'] = 0;\n\t\t\$" . "conf->select->lang['lv'] = 0;\n\t\t\$" . "conf->select->lang['hu-HU'] = 0;\n\t\t\$" . "conf->select->lang['mt'] = 0;\n\t\t\$" . "conf->select->lang['nl-NL'] = 0;\n\t\t\$" . "conf->select->lang['no'] = 0;\n\t\t\$" . "conf->select->lang['pl'] = 0;\n\t\t\$" . "conf->select->lang['pt-PT'] = 0;\n\t\t\$" . "conf->select->lang['ro'] = 0;\n\t\t\$" . "conf->select->lang['sr'] = 0;\n\t\t\$" . "conf->select->lang['sl'] = 0;\n\t\t\$" . "conf->select->lang['sk'] = 0;\n\t\t\$" . "conf->select->lang['fi-FI'] = 0;\n\t\t\$" . "conf->select->lang['sv-SE'] = 0;\n\t\t\$" . "conf->select->lang['el-GR'] = 0;\n\t\t\$" . "conf->select->lang['bg'] = 0;\n\t\t\$" . "conf->select->lang['mk'] = 0;\n\t\t\$" . "conf->trans['en_US'] = 'english';\n\t\t\$" . "conf->trans['de_DE'] = 'deutsch';\n\t\t\$" . "conf->trans['fr_FR'] = 'français';\n\t\t\$" . "conf->trans['es_ES'] = 'Español';\n\t\t?>\n\t\t");
fclose($capfile);
$conf->user->lang = 'en_US';
$langs->setDefaultLang($conf->user->lang);
$langs->load("main");
// index.php#conf
if (file_exists('conf/conf.php')) {
header('Location: index.php#conf');
exit;
} else {
die('Permision problems detectet pleas fix this: Can\'t create conf.php file in folder conf/<br>Please give this folder conf/ the group apache and the mod rwxrwxr-x');
示例14: Translate
function shipment_generate_pdf(&$shipment, $hidedetails, $hidedesc, $hideref)
{
global $conf, $langs;
$db =& $this->db;
// Il faut recharger les lignes qui viennent juste d'être créées
$shipment->fetch($shipment->id);
/*echo '<pre>';
print_r($shipment);
exit;*/
$outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS) {
$newlang = $shipment->client->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$result = expedition_pdf_create($db, $shipment, $shipment->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result > 0) {
$objectref = dol_sanitizeFileName($shipment->ref);
$dir = $conf->expedition->dir_output . "/sending/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf";
return $file;
}
return '';
}
示例15: send
/**
* Check if notification are active for couple action/company.
* If yes, send mail and save trace into llx_notify.
*
* @param string $notifcode Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param Object $object Object the notification deals on
* @return int <0 if KO, or number of changes if OK
*/
function send($notifcode, $object)
{
global $user, $conf, $langs, $mysoc, $dolibarr_main_url_root;
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_syslog(get_class($this) . "::send notifcode=" . $notifcode . ", object=" . $object->id);
$langs->load("other");
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
// This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Define some vars
$application = $mysoc->name;
//if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
$replyto = $conf->notification->email_from;
$filename = basename($file);
$mimefile = dol_mimetype($file);
$object_type = '';
$link = '';
$num = 0;
if (!in_array($notifcode, array('BILL_VALIDATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', 'FICHINTER_VALIDATE', 'ORDER_SUPPLIER_VALIDATE', 'ORDER_SUPPLIER_APPROVE', 'ORDER_SUPPLIER_REFUSE', 'SHIPPING_VALIDATE'))) {
return 0;
}
$oldref = empty($object->oldref) ? $object->ref : $object->oldref;
$newref = empty($object->newref) ? $object->ref : $object->newref;
// Check notification per third party
$sql = "SELECT s.nom, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
$sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
$sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as c,";
$sql .= " " . MAIN_DB_PREFIX . "c_action_trigger as a,";
$sql .= " " . MAIN_DB_PREFIX . "notify_def as n,";
$sql .= " " . MAIN_DB_PREFIX . "societe as s";
$sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
$sql .= " AND n.fk_soc = s.rowid";
if (is_numeric($notifcode)) {
$sql .= " AND n.fk_action = " . $notifcode;
} else {
$sql .= " AND a.code = '" . $notifcode . "'";
}
// New usage
$sql .= " AND s.rowid = " . $object->socid;
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
if ($num > 0) {
$i = 0;
while ($i < $num && !$error) {
$obj = $this->db->fetch_object($result);
$sendto = dolGetFirstLastname($obj->firstname, $obj->lastname) . " <" . $obj->email . ">";
$notifcodedefid = $obj->adid;
if (dol_strlen($obj->email)) {
// Set output language
$outputlangs = $langs;
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($obj->default_lang);
}
switch ($notifcode) {
case 'BILL_VALIDATE':
$link = '/compta/facture.php?facid=' . $object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref);
break;
case 'ORDER_VALIDATE':
$link = '/commande/card.php?id=' . $object->id;
$dir_output = $conf->commande->dir_output;
$object_type = 'order';
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $newref);
break;
case 'PROPAL_VALIDATE':
$link = '/comm/propal.php?id=' . $object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $newref);
break;
case 'FICHINTER_VALIDATE':
$link = '/fichinter/card.php?id=' . $object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $object->ref);
break;
case 'ORDER_SUPPLIER_VALIDATE':
$link = '/fourn/commande/card.php?id=' . $object->id;
$dir_output = $conf->fournisseur->dir_output . '/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
$mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $object->ref, $user->getFullName($langs));
$mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
break;
case 'ORDER_SUPPLIER_APPROVE':
$link = '/fourn/commande/card.php?id=' . $object->id;
//.........这里部分代码省略.........