diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php index 32347362e09..a478ce54ecd 100644 --- a/htdocs/comm/prospect/recap-prospect.php +++ b/htdocs/comm/prospect/recap-prospect.php @@ -27,6 +27,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); $langs->load("companies"); +$langs->load('other'); if ($conf->facture->enabled) $langs->load("bills"); // Security check diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f8c0872c20e..5999f1fd41a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1930,16 +1930,6 @@ class Facture extends CommonInvoice $rangtouse = $rangmax + 1; } - // TODO A virer - // Anciens indicateurs: $price, $remise (a ne plus utiliser) - //$price = $pu; - //$remise = 0; - //if ($remise_percent > 0) - //{ - // $remise = round(($pu * $remise_percent / 100),2); - // $price = ($pu - $remise); - //} - $product_type=$type; if ($fk_product) { @@ -1980,10 +1970,6 @@ class Facture extends CommonInvoice $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; - // TODO Ne plus utiliser - //$this->line->price=($this->type==2?-1:1)*abs($price); - //$this->line->remise=($this->type==2?-1:1)*abs($remise); - $result=$this->line->insert(); if ($result > 0) { diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index ab3d5dcb2a1..3a96441a39b 100755 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -33,6 +33,13 @@ $langs->load("companies"); $langs->load("other"); $langs->load("compta"); +$date_startmonth=GETPOST('date_startmonth'); +$date_startday=GETPOST('date_startday'); +$date_startyear=GETPOST('date_startyear'); +$date_endmonth=GETPOST('date_endmonth'); +$date_endday=GETPOST('date_endday'); +$date_endyear=GETPOST('date_endyear'); + // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -64,8 +71,8 @@ if ($pastmonth == 0) $pastmonthyear--; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); if (empty($date_start) || empty($date_end)) // We define date_start and date_end { @@ -73,7 +80,9 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $nom=$langs->trans("PurchasesJournal"); -//$nomlink=; +$nomlink=''; +$periodlink=''; +$exportlink=''; $builddate=time(); $description=$langs->trans("DescPurchasesJournal"); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index ea3e128c567..66e76117c8f 100755 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -34,6 +34,13 @@ $langs->load("companies"); $langs->load("other"); $langs->load("compta"); +$date_startmonth=GETPOST('date_startmonth'); +$date_startday=GETPOST('date_startday'); +$date_startyear=GETPOST('date_startyear'); +$date_endmonth=GETPOST('date_endmonth'); +$date_endday=GETPOST('date_endday'); +$date_endyear=GETPOST('date_endyear'); + // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -66,8 +73,8 @@ if ($pastmonth == 0) $pastmonthyear--; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); if (empty($date_start) || empty($date_end)) // We define date_start and date_end { @@ -75,7 +82,9 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $nom=$langs->trans("SellsJournal"); -//$nomlink=; +$nomlink=''; +$periodlink=''; +$exportlink=''; $builddate=time(); $description=$langs->trans("DescSellsJournal"); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); @@ -113,25 +122,28 @@ if ($result) { $obj = $db->fetch_object($result); // les variables - $cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER))?$conf->global->COMPTA_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef"); - $compta_soc = (! empty($obj->code_compta))?$obj->code_compta:$cptcli; + $cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER)?$conf->global->COMPTA_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef")); + $compta_soc = (! empty($obj->code_compta)?$obj->code_compta:$cptcli); $compta_prod = $obj->accountancy_code_sell; if (empty($compta_prod)) { - if($obj->product_type == 0) $compta_prod = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT))?$conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT:$langs->trans("CodeNotDef"); - else $compta_prod = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT))?$conf->global->COMPTA_SERVICE_SOLD_ACCOUNT:$langs->trans("CodeNotDef"); + if($obj->product_type == 0) $compta_prod = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT)?$conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT:$langs->trans("CodeNotDef")); + else $compta_prod = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT)?$conf->global->COMPTA_SERVICE_SOLD_ACCOUNT:$langs->trans("CodeNotDef")); } - $cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT))?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef"); - $compta_tva = (! empty($obj->accountancy_code))?$obj->accountancy_code:$cpttva; + $cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef")); + $compta_tva = (! empty($obj->accountancy_code)?$obj->accountancy_code:$cpttva); //la ligne facture $tabfac[$obj->rowid]["date"] = $obj->datef; $tabfac[$obj->rowid]["ref"] = $obj->facnumber; $tabfac[$obj->rowid]["type"] = $obj->type; + if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc]=0; + if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod]=0; + if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva]=0; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; - $tabcompany[$obj->rowid]=array('id'=>$obj->socid,'name'=>$obj->name,'client'=>$obj->client); + $tabcompany[$obj->rowid]=array('id'=>$obj->socid, 'name'=>$obj->name, 'client'=>$obj->client); $i++; } } @@ -217,6 +229,6 @@ print ""; // End of page -$db->close(); llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 830b18607bb..a2e6045fe2b 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,10 +32,18 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); $langs->load("bills"); +$date_startmonth=GETPOST('date_startmonth'); +$date_startday=GETPOST('date_startday'); +$date_startyear=GETPOST('date_startyear'); +$date_endmonth=GETPOST('date_endmonth'); +$date_endday=GETPOST('date_endday'); +$date_endyear=GETPOST('date_endyear'); + // Security check $socid = GETPOST('socid','int'); if ($user->societe_id > 0) $socid = $user->societe_id; -if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) accessforbidden(); +if (! $user->rights->compta->resultat->lire && ! $user->rights->accounting->comptarapport->lire) + accessforbidden(); // Date range $year=GETPOST("year"); @@ -49,8 +57,8 @@ if (empty($year)) $month_current = strftime("%m",dol_now()); $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); // Date for local PHP server +$date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { @@ -86,9 +94,7 @@ else } // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') -$modecompta = $conf->global->COMPTA_MODE; -if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); - +$modecompta=(GETPOST("modecompta")?GETPOST("modecompta"):$conf->global->COMPTA_MODE); /* @@ -99,6 +105,13 @@ llxHeader(); $form=new Form($db); +$nomlink=''; +$periodlink=''; +$exportlink=''; + +$total_ht=0; +$total_ttc=0; + // Affiche en-tete de rapport if ($modecompta=="CREANCES-DETTES") { @@ -128,7 +141,8 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl print ''; print ''; print ''; -if ($modecompta == 'CREANCES-DETTES') print ""; +if ($modecompta == 'CREANCES-DETTES') + print ""; print ""; print "\n"; @@ -144,9 +158,12 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut IN (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $sql.= " AND f.type IN (0,1,2)"; + else + $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } else { @@ -162,7 +179,8 @@ else $sql.= " WHERE p.rowid = pf.fk_paiement"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.fk_soc = s.rowid"; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; @@ -183,11 +201,12 @@ if ($result) { print ""; print "\n"; - if ($modecompta == 'CREANCES-DETTES') print "\n"; + if ($modecompta == 'CREANCES-DETTES') + print "\n"; print "\n"; - $total_ht = $total_ht + $objp->amount_ht; - $total_ttc = $total_ttc + $objp->amount_ttc; + $total_ht += (isset($objp->amount_ht)?$objp->amount_ht:0); + $total_ttc += $objp->amount_ttc; print "\n"; $i++; } @@ -208,7 +227,8 @@ if ($modecompta != 'CREANCES-DETTES') $sql.= " AND p.fk_bank = b.rowid"; $sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND ba.entity = ".$conf->entity; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY nom, idp"; $sql.= " ORDER BY nom"; @@ -226,11 +246,13 @@ if ($modecompta != 'CREANCES-DETTES') print ""; print "\n"; + if ($modecompta == 'CREANCES-DETTES') + print "\n"; print "\n"; - $total_ht = $total_ht + $objp->amount_ht; - $total_ttc = $total_ttc + $objp->amount_ttc; + $total_ht += (isset($objp->amount_ht)?$objp->amount_ht:0); + $total_ttc += $objp->amount_ttc; + print "\n"; $i++; } @@ -250,7 +272,8 @@ if ($total_ttc == 0) } print ''; -if ($modecompta == 'CREANCES-DETTES') print ''; +if ($modecompta == 'CREANCES-DETTES') + print ''; print ''; print ''; @@ -265,9 +288,12 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut IN (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $sql.= " AND f.type IN (0,1,2)"; + else + $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } else { @@ -279,7 +305,8 @@ else $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s"; $sql.= " ON f.fk_soc = s.rowid"; $sql.= " WHERE p.rowid = pf.fk_paiementfourn "; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; @@ -306,13 +333,15 @@ if ($result) { print ""; print "\n"; - if ($modecompta == 'CREANCES-DETTES') print "\n"; + if ($modecompta == 'CREANCES-DETTES') + print "\n"; print "\n"; - $total_ht = $total_ht - $objp->amount_ht; - $total_ttc = $total_ttc - $objp->amount_ttc; - $subtotal_ht = $subtotal_ht + $objp->amount_ht; - $subtotal_ttc = $subtotal_ttc + $objp->amount_ttc; + $total_ht -= (isset($objp->amount_ht)?$objp->amount_ht:0); + $total_ttc -= $objp->amount_ttc; + $subtotal_ht += (isset($objp->amount_ht)?$objp->amount_ht:0); + $subtotal_ttc += $objp->amount_ttc; + print "\n"; $i++; } @@ -330,7 +359,8 @@ if ($result) { dol_print_error($db); } print ''; -if ($modecompta == 'CREANCES-DETTES') print ''; +if ($modecompta == 'CREANCES-DETTES') + print ''; print ''; print ''; @@ -349,7 +379,8 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " WHERE cs.fk_type = c.id"; $sql.= " AND c.deductible = 0"; - if ($date_start && $date_end) $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; } else { @@ -360,7 +391,8 @@ else $sql.= " WHERE p.fk_charge = cs.rowid"; $sql.= " AND cs.fk_type = c.id"; $sql.= " AND c.deductible = 0"; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } $sql.= " AND cs.entity = ".$conf->entity; $sql.= " GROUP BY c.libelle"; @@ -378,10 +410,10 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); - $total_ht = $total_ht - $obj->amount; - $total_ttc = $total_ttc - $obj->amount; - $subtotal_ht = $subtotal_ht + $obj->amount; - $subtotal_ttc = $subtotal_ttc + $obj->amount; + $total_ht -= $obj->amount; + $total_ttc -= $obj->amount; + $subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; $var = !$var; print ""; @@ -402,7 +434,8 @@ if ($result) { dol_print_error($db); } print ''; -if ($modecompta == 'CREANCES-DETTES') print ''; +if ($modecompta == 'CREANCES-DETTES') + print ''; print ''; print ''; @@ -420,7 +453,8 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " WHERE cs.fk_type = c.id"; $sql.= " AND c.deductible = 1"; - if ($date_start && $date_end) $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; $sql.= " AND cs.entity = ".$conf->entity; $sql.= " GROUP BY c.libelle"; $sql.= " ORDER BY c.libelle"; @@ -434,7 +468,8 @@ else $sql.= " WHERE p.fk_charge = cs.rowid"; $sql.= " AND cs.fk_type = c.id"; $sql.= " AND c.deductible = 1"; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND cs.entity = ".$conf->entity; $sql.= " GROUP BY c.libelle"; $sql.= " ORDER BY c.libelle"; @@ -452,15 +487,16 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); - $total_ht = $total_ht - $obj->amount; - $total_ttc = $total_ttc - $obj->amount; - $subtotal_ht = $subtotal_ht + $obj->amount; - $subtotal_ttc = $subtotal_ttc + $obj->amount; + $total_ht -= $obj->amount; + $total_ttc -= $obj->amount; + $subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; $var = !$var; print ""; print ''; - if ($modecompta == 'CREANCES-DETTES') print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''; print ''; print ''; $i++; @@ -476,7 +512,8 @@ if ($result) { dol_print_error($db); } print ''; -if ($modecompta == 'CREANCES-DETTES') print ''; +if ($modecompta == 'CREANCES-DETTES') + print ''; print ''; print ''; @@ -488,7 +525,8 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti print ''; print ''; - if ($modecompta == 'CREANCES-DETTES') print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''; print ''; print ''; @@ -512,9 +550,12 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_statut IN (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $sql.= " AND f.type IN (0,1,2)"; + else + $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; @@ -529,11 +570,11 @@ if ($modecompta == 'CREANCES-DETTES') while ($i < $num) { $obj = $db->fetch_object($result); - $amount = $amount - $obj->amount; - //$total_ht = $total_ht - $obj->amount; - $total_ttc = $total_ttc - $obj->amount; - //$subtotal_ht = $subtotal_ht - $obj->amount; - $subtotal_ttc = $subtotal_ttc - $obj->amount; + $amount -= $obj->amount; + //$total_ht -= $obj->amount; + $total_ttc -= $obj->amount; + //$subtotal_ht -= $obj->amount; + $subtotal_ttc -= $obj->amount; $i++; } } @@ -551,9 +592,12 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= " WHERE f.fk_statut IN (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $sql.= " AND f.type IN (0,1,2)"; + else + $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; @@ -568,11 +612,11 @@ if ($modecompta == 'CREANCES-DETTES') while ($i < $num) { $obj = $db->fetch_object($result); - $amount = $amount + $obj->amount; - //$total_ht = $total_ht + $obj->amount; - $total_ttc = $total_ttc + $obj->amount; - //$subtotal_ht = $subtotal_ht + $obj->amount; - $subtotal_ttc = $subtotal_ttc + $obj->amount; + $amount += $obj->amount; + //$total_ht += $obj->amount; + $total_ttc += $obj->amount; + //$subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; $i++; } @@ -593,7 +637,8 @@ else $sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " WHERE amount > 0"; - if ($date_start && $date_end) $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'"; $sql.= " AND t.entity = ".$conf->entity; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; @@ -608,11 +653,11 @@ else while ($i < $num) { $obj = $db->fetch_object($result); - $amount = $amount - $obj->amount; - $total_ht = $total_ht - $obj->amount; - $total_ttc = $total_ttc - $obj->amount; - $subtotal_ht = $subtotal_ht - $obj->amount; - $subtotal_ttc = $subtotal_ttc - $obj->amount; + $amount -= $obj->amount; + $total_ht -= $obj->amount; + $total_ttc -= $obj->amount; + $subtotal_ht -= $obj->amount; + $subtotal_ttc -= $obj->amount; $i++; } @@ -623,7 +668,8 @@ else } print ""; print "\n"; - if ($modecompta == 'CREANCES-DETTES') print "\n"; + if ($modecompta == 'CREANCES-DETTES') + print "\n"; print "\n"; print "\n"; @@ -632,7 +678,8 @@ else $sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " WHERE amount < 0"; - if ($date_start && $date_end) $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'"; + if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'"; $sql.= " AND t.entity = ".$conf->entity; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; @@ -647,11 +694,11 @@ else while ($i < $num) { $obj = $db->fetch_object($result); - $amount = $amount + $obj->amount; - $total_ht = $total_ht + $obj->amount; - $total_ttc = $total_ttc + $obj->amount; - $subtotal_ht = $subtotal_ht + $obj->amount; - $subtotal_ttc = $subtotal_ttc + $obj->amount; + $amount += $obj->amount; + $total_ht += $obj->amount; + $total_ttc += $obj->amount; + $subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; $i++; } @@ -664,7 +711,8 @@ else } print ""; print "\n"; - if ($modecompta == 'CREANCES-DETTES') print "\n"; + if ($modecompta == 'CREANCES-DETTES') + print "\n"; print "\n"; print "\n"; } @@ -673,7 +721,8 @@ else if ($mysoc->tva_assuj != 'franchise') // Assujeti { print ''; - if ($modecompta == 'CREANCES-DETTES') print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''; print ''; print ''; } @@ -687,7 +736,8 @@ if ($mysoc->tva_assuj != 'franchise') // Assujeti print ''; print ''; - if ($modecompta == 'CREANCES-DETTES') print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''; print ''; print ''; } diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index bbb6c5511be..2ba45b22a7d 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -40,13 +40,11 @@ else { // Security check $socid = GETPOST('socid','int'); if ($user->societe_id > 0) $socid = $user->societe_id; -if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) -accessforbidden(); +if (! $user->rights->compta->resultat->lire && ! $user->rights->accounting->comptarapport->lire) + accessforbidden(); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') -$modecompta = $conf->global->COMPTA_MODE; -if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); - +$modecompta=(GETPOST("modecompta")?GETPOST("modecompta"):$conf->global->COMPTA_MODE); /* @@ -57,6 +55,9 @@ llxHeader(); $form=new Form($db); +$nomlink=''; +$exportlink=''; + // Affiche en-tete du rapport if ($modecompta == 'CREANCES-DETTES') { @@ -125,7 +126,7 @@ if ($result) while ($i < $num) { $row = $db->fetch_object($result); - $encaiss[$row->dm] = $row->amount_ht; + $encaiss[$row->dm] = (isset($row->amount_ht)?$row->amount_ht:0); $encaiss_ttc[$row->dm] = $row->amount_ttc; $i++; } @@ -159,7 +160,10 @@ if ($modecompta != 'CREANCES-DETTES') { $row = $db->fetch_object($result); - $encaiss[$row->dm] += $row->amount_ht; + if (! isset($encaiss[$row->dm])) $encaiss[$row->dm]=0; + $encaiss[$row->dm] += (isset($row->amount_ht)?$row->amount_ht:0); + + if (! isset($encaiss_ttc[$row->dm])) $encaiss_ttc[$row->dm]=0; $encaiss_ttc[$row->dm] += $row->amount_ttc; $i++; @@ -208,7 +212,10 @@ if ($result) { $row = $db->fetch_object($result); - $decaiss[$row->dm] = $row->amount_ht; + if (! isset($decaiss[$row->dm])) $decaiss[$row->dm]=0; + $decaiss[$row->dm] = (isset($row->amount_ht)?$row->amount_ht:0); + + if (! isset($decaiss_ttc[$row->dm])) $decaiss_ttc[$row->dm]=0; $decaiss_ttc[$row->dm] = $row->amount_ttc; $i++; @@ -246,7 +253,10 @@ if ($modecompta == 'CREANCES-DETTES') while ($i < $num) { $obj = $db->fetch_object($result); + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; $decaiss[$obj->dm] += $obj->amount; + + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; $decaiss_ttc[$obj->dm] += $obj->amount; $i++; @@ -274,7 +284,10 @@ if ($modecompta == 'CREANCES-DETTES') while ($i < $num) { $obj = $db->fetch_object($result); + if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; $encaiss[$obj->dm] += $obj->amount; + + if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0; $encaiss_ttc[$obj->dm] += $obj->amount; $i++; @@ -302,7 +315,10 @@ else { while ($i < $num) { $obj = $db->fetch_object($result); + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; $decaiss[$obj->dm] += $obj->amount; + + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; $decaiss_ttc[$obj->dm] += $obj->amount; $i++; @@ -328,7 +344,10 @@ else { while ($i < $num) { $obj = $db->fetch_object($result); + if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; $encaiss[$obj->dm] += $obj->amount; + + if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0; $encaiss_ttc[$obj->dm] += $obj->amount; $i++; @@ -346,7 +365,7 @@ $subtotal_ht = 0; $subtotal_ttc = 0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount_ht, sum(cs.amount) as amount_ttc"; + $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " WHERE cs.fk_type = c.id"; @@ -354,7 +373,7 @@ if ($modecompta == 'CREANCES-DETTES') } else { - $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ht, sum(p.amount) as amount_ttc"; + $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p"; @@ -375,8 +394,11 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); - $decaiss[$obj->dm] += $obj->amount_ht; - $decaiss_ttc[$obj->dm] += $obj->amount_ttc; + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; + $decaiss[$obj->dm] += $obj->amount; + + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; + $decaiss_ttc[$obj->dm] += $obj->amount; $i++; } @@ -393,7 +415,7 @@ $subtotal_ht = 0; $subtotal_ttc = 0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount_ht, sum(cs.amount) as amount_ttc"; + $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " WHERE cs.fk_type = c.id"; @@ -401,7 +423,7 @@ if ($modecompta == 'CREANCES-DETTES') } else { - $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ht, sum(p.amount) as amount_ttc"; + $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p"; @@ -422,8 +444,11 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); - $decaiss[$obj->dm] += $obj->amount_ht; - $decaiss_ttc[$obj->dm] += $obj->amount_ttc; + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; + $decaiss[$obj->dm] += $obj->amount; + + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; + $decaiss_ttc[$obj->dm] += $obj->amount; $i++; } @@ -479,17 +504,19 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) $case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage)); print '"; print '"; @@ -523,7 +550,9 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) print ''; + $in=(isset($totentrees[$annee])?price2num($totentrees[$annee], 'MT'):0); + $out=(isset($totsorties[$annee])?price2num($totsorties[$annee],' MT'):0); + print price($in-$out).''; // print ''; } } @@ -533,6 +562,5 @@ print "
  ".$langs->trans("AmountHT")."".$langs->trans("AmountHT")."".$langs->trans("AmountTTC")."
 ".$langs->trans("Bills").' '.$objp->nom."".price($objp->amount_ht)."".price($objp->amount_ht)."".price($objp->amount_ttc)."
 ".$langs->trans("Bills")." ".$langs->trans("Other")." (".$langs->trans("PaymentsNotLinkedToInvoice").")\n"; - if ($modecompta == 'CREANCES-DETTES') print "".price($objp->amount_ht)."".price($objp->amount_ht)."".price($objp->amount_ttc)."
'.price($total_ht).''.price($total_ht).''.price($total_ttc).'
 ".$langs->trans("Bills")." socid."\">".$objp->nom."".price(-$objp->amount_ht)."".price(-$objp->amount_ht)."".price(-$objp->amount_ttc)."
'.price(-$subtotal_ht).''.price(-$subtotal_ht).''.price(-$subtotal_ttc).'
 
'.price(-$subtotal_ht).''.price(-$subtotal_ht).''.price(-$subtotal_ttc).'
 '.$obj->nom.''.price(-$obj->amount).''.price(-$obj->amount).''.price(-$obj->amount).'
'.price(-$subtotal_ht).''.price(-$subtotal_ht).''.price(-$subtotal_ttc).'
'.$langs->trans("Profit").''.price($total_ht).''.price($total_ht).''.price($total_ttc).'
 ".$langs->trans("VATPaid")."".price($amount)."".price($amount)."".price($amount)."
 ".$langs->trans("VATCollected")."".price($amount)."".price($amount)."".price($amount)."
  '.price(price2num($subtotal_ttc,'MT')).'
'.$langs->trans("Profit").''.price(price2num($total_ht,'MT')).''.price(price2num($total_ht,'MT')).''.price(price2num($total_ttc,'MT')).'
 '; - if ($decaiss_ttc[$case] != 0) + if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) { print ''.price(price2num($decaiss_ttc[$case],'MT')).''; + if (! isset($totsorties[$annee])) $totsorties[$annee]=0; $totsorties[$annee]+=$decaiss_ttc[$case]; } print " '; - if ($encaiss_ttc[$case] != 0) + if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0) { print ''.price(price2num($encaiss_ttc[$case],'MT')).''; + if (! isset($totentrees[$annee])) $totentrees[$annee]=0; $totentrees[$annee]+=$encaiss_ttc[$case]; } print " '; if (isset($totentrees[$annee]) || isset($totsorties[$annee])) { - print price(price2num($totentrees[$annee]-$totsorties[$annee],'MT')).' 
"; llxFooter(); - $db->close(); -?> +?> \ No newline at end of file diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f08e8a62331..973f4882654 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2189,11 +2189,6 @@ abstract class CommonObject { $nb=0; - //if (empty($this->table_element_line)) dol_print_error('Call hasPredefinedProducts on a class with no table_element_line property'); - - //$sql ='SELECT COUNT(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; - //$sql.='WHERE ...'; - //var_dump($this->lines); foreach($this->lines as $key => $val) { $qualified=0; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c52efec205e..2a0237261aa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -33,7 +33,7 @@ if (! function_exists('json_encode')) { - include_once(DOL_DOCUMENT_ROOT ."/core/lib/json.lib.php"); + include_once(DOL_DOCUMENT_ROOT ."/core/lib/json.lib.php"); } /** @@ -77,11 +77,11 @@ function getStaticMember($class, $member) */ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) { - require_once(DOL_DOCUMENT_ROOT ."/core/db/".$type.".class.php"); + require_once(DOL_DOCUMENT_ROOT ."/core/db/".$type.".class.php"); - $class='DoliDB'.ucfirst($type); - $dolidb=new $class($type, $host, $user, $pass, $name, $port); - return $dolidb; + $class='DoliDB'.ucfirst($type); + $dolidb=new $class($type, $host, $user, $pass, $name, $port); + return $dolidb; } /** @@ -119,34 +119,34 @@ function getEntity($element=false, $shared=false) */ function getBrowserInfo() { - $name='unknown'; $version=''; $os='unknown'; $phone=''; + $name='unknown'; $version=''; $os='unknown'; $phone=''; - // If phone/smartphone, we set phone os name. - if (preg_match('/android/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='android'; } - elseif (preg_match('/blackberry/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='blackberry'; } - elseif (preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) { $os='ios'; $phone='iphone'; } - elseif (preg_match('/ipod/i',$_SERVER["HTTP_USER_AGENT"])) { $os='ios'; $phone='iphone'; } - elseif (preg_match('/palm/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='palm'; } - elseif (preg_match('/symbian/i',$_SERVER["HTTP_USER_AGENT"])) { $os='symbian'; $phone='unknown'; } - elseif (preg_match('/webos/i',$_SERVER["HTTP_USER_AGENT"])) { $os='webos'; $phone='unknown'; } - elseif (preg_match('/maemo/i',$_SERVER["HTTP_USER_AGENT"])) { $os='maemo'; $phone='unknown'; } - // MS products at end - elseif (preg_match('/iemobile/i',$_SERVER["HTTP_USER_AGENT"])) { $os='windows'; $phone='unkown'; } - elseif (preg_match('/windows ce/i',$_SERVER["HTTP_USER_AGENT"])) { $os='windows'; $phone='unkown'; } - // Name - if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='firefox'; $version=$reg[2]; } - elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='chrome'; $version=$reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string - elseif (preg_match('/chrome/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='chrome'; } - elseif (preg_match('/iceweasel/i',$_SERVER["HTTP_USER_AGENT"])) { $name='iceweasel'; $version=$reg[2]; } - elseif (preg_match('/epiphany/i',$_SERVER["HTTP_USER_AGENT"])) { $name='epiphany'; $version=$reg[2]; } - elseif ((empty($phone) || preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) && preg_match('/safari(\/|\s)([\d\.]*)/i',$_SERVER["HTTP_USER_AGENT"], $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not. - elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='opera'; $version=$reg[2]; } - elseif (preg_match('/msie(\/|\s)([\d\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='ie'; $version=$reg[2]; } // MS products at end - // Other - $firefox=0; - if (in_array($name,array('firefox','iceweasel'))) $firefox=1; + // If phone/smartphone, we set phone os name. + if (preg_match('/android/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='android'; } + elseif (preg_match('/blackberry/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='blackberry'; } + elseif (preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) { $os='ios'; $phone='iphone'; } + elseif (preg_match('/ipod/i',$_SERVER["HTTP_USER_AGENT"])) { $os='ios'; $phone='iphone'; } + elseif (preg_match('/palm/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='palm'; } + elseif (preg_match('/symbian/i',$_SERVER["HTTP_USER_AGENT"])) { $os='symbian'; $phone='unknown'; } + elseif (preg_match('/webos/i',$_SERVER["HTTP_USER_AGENT"])) { $os='webos'; $phone='unknown'; } + elseif (preg_match('/maemo/i',$_SERVER["HTTP_USER_AGENT"])) { $os='maemo'; $phone='unknown'; } + // MS products at end + elseif (preg_match('/iemobile/i',$_SERVER["HTTP_USER_AGENT"])) { $os='windows'; $phone='unkown'; } + elseif (preg_match('/windows ce/i',$_SERVER["HTTP_USER_AGENT"])) { $os='windows'; $phone='unkown'; } + // Name + if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='firefox'; $version=$reg[2]; } + elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='chrome'; $version=$reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string + elseif (preg_match('/chrome/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='chrome'; } + elseif (preg_match('/iceweasel/i',$_SERVER["HTTP_USER_AGENT"])) { $name='iceweasel'; $version=$reg[2]; } + elseif (preg_match('/epiphany/i',$_SERVER["HTTP_USER_AGENT"])) { $name='epiphany'; $version=$reg[2]; } + elseif ((empty($phone) || preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) && preg_match('/safari(\/|\s)([\d\.]*)/i',$_SERVER["HTTP_USER_AGENT"], $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not. + elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='opera'; $version=$reg[2]; } + elseif (preg_match('/msie(\/|\s)([\d\.]*)/i', $_SERVER["HTTP_USER_AGENT"], $reg)) { $name='ie'; $version=$reg[2]; } // MS products at end + // Other + $firefox=0; + if (in_array($name,array('firefox','iceweasel'))) $firefox=1; - return array('browsername'=>$name, 'browserversion'=>$version, 'browseros'=>$os, 'phone'=>$phone, 'browserfirefox'=>$firefox); + return array('browsername'=>$name, 'browserversion'=>$version, 'browseros'=>$os, 'phone'=>$phone, 'browserfirefox'=>$firefox); } /** @@ -156,10 +156,10 @@ function getBrowserInfo() */ function dol_shutdown() { - global $conf,$user,$langs,$db; - $disconnectdone=false; $depth=0; - if (is_object($db) && ! empty($db->connected)) { $depth=$db->transaction_opened; $disconnectdone=$db->close(); } - dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG)); + global $conf,$user,$langs,$db; + $disconnectdone=false; $depth=0; + if (is_object($db) && ! empty($db->connected)) { $depth=$db->transaction_opened; $disconnectdone=$db->close(); } + dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG)); } @@ -177,7 +177,7 @@ function GETPOST($paramname,$check='',$method=0) elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:''; elseif ($method==3) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:''); - else return 'BadParameter'; + else return 'BadParameter'; if (! empty($check)) { @@ -191,9 +191,9 @@ function GETPOST($paramname,$check='',$method=0) elseif ($check == 'alpha') { $out=trim($out); - // '"' is dangerous because param in url can close the href= or src= and add javascript functions. - // '../' is dangerous because it allows dir transversals - if (preg_match('/"/',$out)) $out=''; + // '"' is dangerous because param in url can close the href= or src= and add javascript functions. + // '../' is dangerous because it allows dir transversals + if (preg_match('/"/',$out)) $out=''; else if (preg_match('/\.\.\//',$out)) $out=''; } elseif ($check == 'array') @@ -215,7 +215,7 @@ function GETPOST($paramname,$check='',$method=0) */ function dol_getprefix() { - return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); + return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); } /** @@ -231,12 +231,12 @@ function dol_getprefix() */ function dol_include_once($relpath, $classname='') { - global $conf,$langs,$user,$mysoc; // Other global var must be retreived with $GLOBALS['var'] - if (! empty($classname) && ! class_exists($classname)) { - return @include dol_buildpath($relpath); - } else { - return @include_once dol_buildpath($relpath); - } + global $conf,$langs,$user,$mysoc; // Other global var must be retreived with $GLOBALS['var'] + if (! empty($classname) && ! class_exists($classname)) { + return @include dol_buildpath($relpath); + } else { + return @include_once dol_buildpath($relpath); + } } @@ -249,47 +249,47 @@ function dol_include_once($relpath, $classname='') */ function dol_buildpath($path, $type=0) { - if (empty($type)) // For a filesystem path - { - $res = DOL_DOCUMENT_ROOT.$path; // Standard value - if (defined('DOL_DOCUMENT_ROOT_ALT') && DOL_DOCUMENT_ROOT_ALT) // We check only if alternate feature is used - { - if (! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path; - } - } - else // For an url path - { - // We try to get local path of file on filesystem from url - // Note that trying to know if a file on disk exist by forging path on disk from url - // works only for some web server and some setup. This is bugged when - // using proxy, rewriting, virtual path, etc... - if ($type == 1) - { - $res = DOL_URL_ROOT.$path; // Standard value - if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used - { - preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i',$path,$regs); // Take part before '?' - if (! empty($regs[1])) - { - if (! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $res = DOL_URL_ROOT_ALT.$path; - } - } - } - else if ($type == 2) - { - $res = DOL_MAIN_URL_ROOT.$path; // Standard value - if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used - { - preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i',$path,$regs); // Take part before '?' - if (! empty($regs[1])) - { - if (! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $res = DOL_MAIN_URL_ROOT_ALT.$path; - } - } - } - } + if (empty($type)) // For a filesystem path + { + $res = DOL_DOCUMENT_ROOT.$path; // Standard value + if (defined('DOL_DOCUMENT_ROOT_ALT') && DOL_DOCUMENT_ROOT_ALT) // We check only if alternate feature is used + { + if (! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path; + } + } + else // For an url path + { + // We try to get local path of file on filesystem from url + // Note that trying to know if a file on disk exist by forging path on disk from url + // works only for some web server and some setup. This is bugged when + // using proxy, rewriting, virtual path, etc... + if ($type == 1) + { + $res = DOL_URL_ROOT.$path; // Standard value + if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used + { + preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i',$path,$regs); // Take part before '?' + if (! empty($regs[1])) + { + if (! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $res = DOL_URL_ROOT_ALT.$path; + } + } + } + else if ($type == 2) + { + $res = DOL_MAIN_URL_ROOT.$path; // Standard value + if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used + { + preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i',$path,$regs); // Take part before '?' + if (! empty($regs[1])) + { + if (! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $res = DOL_MAIN_URL_ROOT_ALT.$path; + } + } + } + } - return $res; + return $res; } /** @@ -301,15 +301,15 @@ function dol_buildpath($path, $type=0) */ function dol_clone($object) { - dol_syslog("Functions.lib::dol_clone Clone object"); + dol_syslog("Functions.lib::dol_clone Clone object"); - // We create dynamically a clone function, making a = - if (version_compare(phpversion(), '5.0') < 0 && ! function_exists('clone')) - { - eval('function clone($object){return($object);}'); - } - $myclone=clone($object); - return $myclone; + // We create dynamically a clone function, making a = + if (version_compare(phpversion(), '5.0') < 0 && ! function_exists('clone')) + { + eval('function clone($object){return($object);}'); + } + $myclone=clone($object); + return $myclone; } /** @@ -323,10 +323,10 @@ function dol_clone($object) */ function dol_size($size,$type='') { - global $conf; - if (empty($conf->browser->phone)) return $size; - if ($type == 'width' && $size > 250) return 250; - else return 10; + global $conf; + if (empty($conf->browser->phone)) return $size; + if ($type == 'width' && $size > 250) return 250; + else return 10; } @@ -343,7 +343,7 @@ function dol_size($size,$type='') function dol_sanitizeFileName($str,$newstr='_',$unaccent=1) { $filesystem_forbidden_chars = array('<','>',':','/','\\','?','*','|','"'); - return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); + return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); } /** @@ -356,10 +356,10 @@ function dol_sanitizeFileName($str,$newstr='_',$unaccent=1) */ function dol_string_unaccent($str) { - if (utf8_check($str)) - { - $string = rawurlencode($str); - $replacements = array( + if (utf8_check($str)) + { + $string = rawurlencode($str); + $replacements = array( '%C3%80' => 'A','%C3%81' => 'A', '%C3%88' => 'E','%C3%89' => 'E', '%C3%8C' => 'I','%C3%8D' => 'I', @@ -373,27 +373,27 @@ function dol_string_unaccent($str) ); $string=strtr($string, $replacements); return rawurldecode($string); - } - else - { - $string = strtr( - $str, - "\xC0\xC1\xC2\xC3\xC5\xC7 - \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1 - \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD - \xE0\xE1\xE2\xE3\xE5\xE7\xE8\xE9\xEA\xEB - \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8 - \xF9\xFA\xFB\xFD\xFF", - "AAAAAC - EEEEIIIIDN - OOOOOUUUY - aaaaaceeee - iiiidnooooo - uuuyy" - ); - $string = strtr($string, array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", "\xDF"=>"ss", "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", "\xFC"=>"ue", "\xFE"=>"th")); - return $string; - } + } + else + { + $string = strtr( + $str, + "\xC0\xC1\xC2\xC3\xC5\xC7 + \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1 + \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD + \xE0\xE1\xE2\xE3\xE5\xE7\xE8\xE9\xEA\xEB + \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8 + \xF9\xFA\xFB\xFD\xFF", + "AAAAAC + EEEEIIIIDN + OOOOOUUUY + aaaaaceeee + iiiidnooooo + uuuyy" + ); + $string = strtr($string, array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", "\xDF"=>"ss", "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", "\xFC"=>"ue", "\xFE"=>"th")); + return $string; + } } /** @@ -408,12 +408,12 @@ function dol_string_unaccent($str) */ function dol_string_nospecial($str,$newstr='_',$badchars='') { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); - $forbidden_chars_to_remove=array(); - if (is_array($badchars)) $forbidden_chars_to_replace=$badchars; - //$forbidden_chars_to_remove=array("(",")"); + $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); + $forbidden_chars_to_remove=array(); + if (is_array($badchars)) $forbidden_chars_to_replace=$badchars; + //$forbidden_chars_to_remove=array("(",")"); - return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str)); + return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str)); } /** @@ -424,9 +424,9 @@ function dol_string_nospecial($str,$newstr='_',$badchars='') */ function dol_escape_js($stringtoescape) { - // escape quotes and backslashes, newlines, etc. - $substitjs=array("'"=>"\\'",'\\'=>'\\\\',"'"=>"\\'",'"'=>"\\'","\r"=>'\\r',"\n"=>'\\n',''<\/'); - return strtr($stringtoescape, $substitjs); + // escape quotes and backslashes, newlines, etc. + $substitjs=array("'"=>"\\'",'\\'=>'\\\\',"'"=>"\\'",'"'=>"\\'","\r"=>'\\r',"\n"=>'\\n',''<\/'); + return strtr($stringtoescape, $substitjs); } @@ -439,11 +439,11 @@ function dol_escape_js($stringtoescape) */ function dol_escape_htmltag($stringtoescape,$keepb=0) { - // escape quotes and backslashes, newlines, etc. - $tmp=dol_html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8'); - if ($keepb) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); - else $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n',""=>'',''=>'')); - return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); + // escape quotes and backslashes, newlines, etc. + $tmp=dol_html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8'); + if ($keepb) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); + else $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n',""=>'',''=>'')); + return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); } /** @@ -465,124 +465,124 @@ function dol_escape_htmltag($stringtoescape,$keepb=0) */ function dol_syslog($message, $level=LOG_INFO) { - global $conf,$user,$langs,$_REQUEST; + global $conf,$user,$langs,$_REQUEST; - // If adding log inside HTML page is required - if (! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_LOGTOHTML)) - { - $conf->logbuffer[]=dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; - } + // If adding log inside HTML page is required + if (! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_LOGTOHTML)) + { + $conf->logbuffer[]=dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; + } - // If syslog module enabled - if (! empty($conf->syslog->enabled)) - { - //print $level.' - '.$conf->global->SYSLOG_LEVEL.' - '.$conf->syslog->enabled." \n"; - if ($level > $conf->global->SYSLOG_LEVEL) return; + // If syslog module enabled + if (! empty($conf->syslog->enabled)) + { + //print $level.' - '.$conf->global->SYSLOG_LEVEL.' - '.$conf->syslog->enabled." \n"; + if ($level > $conf->global->SYSLOG_LEVEL) return; - // Translate error message if this is an error message (rare) and langs is loaded - if ($level == LOG_ERR) - { - if (is_object($langs)) - { - $langs->load("errors"); - if ($message != $langs->trans($message)) $message = $langs->trans($message); - } - } + // Translate error message if this is an error message (rare) and langs is loaded + if ($level == LOG_ERR) + { + if (is_object($langs)) + { + $langs->load("errors"); + if ($message != $langs->trans($message)) $message = $langs->trans($message); + } + } - // Add page/script name to log message - $script=isset($_SERVER['PHP_SELF'])?basename($_SERVER['PHP_SELF'],'.php').' ':''; - $message=$script.$message; + // Add page/script name to log message + $script=isset($_SERVER['PHP_SELF'])?basename($_SERVER['PHP_SELF'],'.php').' ':''; + $message=$script.$message; - // Add user to log message - $login='nologin'; - if (is_object($user) && $user->id) $login=$user->login; - $message=sprintf("%-8s",$login)." ".$message; + // Add user to log message + $login='nologin'; + if (is_object($user) && $user->id) $login=$user->login; + $message=sprintf("%-8s",$login)." ".$message; - // Check if log is to a file (SYSLOG_FILE_ON defined) - if (defined("SYSLOG_FILE_ON") && constant("SYSLOG_FILE_ON")) - { - $filelog=SYSLOG_FILE; - $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog); - //print "filelog=".$filelog."\n"; - if (defined("SYSLOG_FILE_NO_ERROR")) $file=@fopen($filelog,"a+"); - else $file=fopen($filelog,"a+"); + // Check if log is to a file (SYSLOG_FILE_ON defined) + if (defined("SYSLOG_FILE_ON") && constant("SYSLOG_FILE_ON")) + { + $filelog=SYSLOG_FILE; + $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog); + //print "filelog=".$filelog."\n"; + if (defined("SYSLOG_FILE_NO_ERROR")) $file=@fopen($filelog,"a+"); + else $file=fopen($filelog,"a+"); - if ($file) - { - $ip='???'; // $ip contains information to identify computer that run the code - if (! empty($_SERVER["REMOTE_ADDR"])) $ip=$_SERVER["REMOTE_ADDR"]; // In most cases. - else if (! empty($_SERVER['SERVER_ADDR'])) $ip=$_SERVER['SERVER_ADDR']; // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) - else if (! empty($_SERVER['COMPUTERNAME'])) $ip=$_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']); // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but usefull if OS defined it). - else if (! empty($_SERVER['LOGNAME'])) $ip='???@'.$_SERVER['LOGNAME']; // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). + if ($file) + { + $ip='???'; // $ip contains information to identify computer that run the code + if (! empty($_SERVER["REMOTE_ADDR"])) $ip=$_SERVER["REMOTE_ADDR"]; // In most cases. + else if (! empty($_SERVER['SERVER_ADDR'])) $ip=$_SERVER['SERVER_ADDR']; // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) + else if (! empty($_SERVER['COMPUTERNAME'])) $ip=$_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']); // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but usefull if OS defined it). + else if (! empty($_SERVER['LOGNAME'])) $ip='???@'.$_SERVER['LOGNAME']; // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). - $liblevelarray=array(LOG_ERR=>'ERROR',LOG_WARNING=>'WARN',LOG_INFO=>'INFO',LOG_DEBUG=>'DEBUG'); - $liblevel=$liblevelarray[$level]; - if (! $liblevel) $liblevel='UNDEF'; + $liblevelarray=array(LOG_ERR=>'ERROR',LOG_WARNING=>'WARN',LOG_INFO=>'INFO',LOG_DEBUG=>'DEBUG'); + $liblevel=$liblevelarray[$level]; + if (! $liblevel) $liblevel='UNDEF'; - $message=dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".sprintf("%-5s",$liblevel)." ".sprintf("%-15s",$ip)." ".$message; + $message=dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".sprintf("%-5s",$liblevel)." ".sprintf("%-15s",$ip)." ".$message; - fwrite($file,$message."\n"); - fclose($file); - // This is for log file, we do not change permissions + fwrite($file,$message."\n"); + fclose($file); + // This is for log file, we do not change permissions - // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments - if (! empty($conf->global->MAIN_ENABLE_LOG_HTML) && ! empty($_GET["log"])) - { - print "\n\n\n"; - } - } - elseif (! defined("SYSLOG_FILE_NO_ERROR")) - { - // Do not use here a call to functions that make call to dol_syslog so making call to langs. A simple print is enough. - print "Error, failed to open file ".$filelog."\n"; - } - } + // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments + if (! empty($conf->global->MAIN_ENABLE_LOG_HTML) && ! empty($_GET["log"])) + { + print "\n\n\n"; + } + } + elseif (! defined("SYSLOG_FILE_NO_ERROR")) + { + // Do not use here a call to functions that make call to dol_syslog so making call to langs. A simple print is enough. + print "Error, failed to open file ".$filelog."\n"; + } + } - // Check if log is to syslog (SYSLOG_SYSLOG_ON defined) - if (defined("SYSLOG_SYSLOG_ON") && constant("SYSLOG_SYSLOG_ON")) - { - if (function_exists('openlog')) // This function does not exists on some ISP (Ex: Free in France) - { - $facility = LOG_USER; - if (defined("SYSLOG_FACILITY") && constant("SYSLOG_FACILITY")) - { - // Exemple: SYSLOG_FACILITY vaut LOG_USER qui vaut 8. On a besoin de 8 dans $facility. - $facility = constant("SYSLOG_FACILITY"); - } + // Check if log is to syslog (SYSLOG_SYSLOG_ON defined) + if (defined("SYSLOG_SYSLOG_ON") && constant("SYSLOG_SYSLOG_ON")) + { + if (function_exists('openlog')) // This function does not exists on some ISP (Ex: Free in France) + { + $facility = LOG_USER; + if (defined("SYSLOG_FACILITY") && constant("SYSLOG_FACILITY")) + { + // Exemple: SYSLOG_FACILITY vaut LOG_USER qui vaut 8. On a besoin de 8 dans $facility. + $facility = constant("SYSLOG_FACILITY"); + } - openlog("dolibarr", LOG_PID | LOG_PERROR, (int) $facility); // (int) is required to avoid error parameter 3 expected to be long - if (! $level) syslog(LOG_ERR, $message); - else syslog($level, $message); - closelog(); - } - } + openlog("dolibarr", LOG_PID | LOG_PERROR, (int) $facility); // (int) is required to avoid error parameter 3 expected to be long + if (! $level) syslog(LOG_ERR, $message); + else syslog($level, $message); + closelog(); + } + } - // Check if log is to syslog (SYSLOG_FIREPHP_ON defined) - if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON") && ! empty($_SERVER["SERVER_NAME"])) //! empty($_SERVER["SERVER_NAME"]) to be sure to enable this in Web mode only - { - try - { - // Warning FirePHPCore must be into PHP include path. It is not possible to use into require_once() a constant from - // database or config file because we must be able to log data before database or config file read. - $oldinclude=get_include_path(); - set_include_path('/usr/share/php/'); - include_once('FirePHPCore/FirePHP.class.php'); - set_include_path($oldinclude); - ob_start(); - $firephp = FirePHP::getInstance(true); - if ($level == LOG_ERR) $firephp->error($message); - elseif ($level == LOG_WARNING) $firephp->warn($message); - elseif ($level == LOG_INFO) $firephp->log($message); - else $firephp->log($message); - } - catch(Exception $e) - { - // Do not use dol_syslog to avoid infinite loop - } - } - } + // Check if log is to syslog (SYSLOG_FIREPHP_ON defined) + if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON") && ! empty($_SERVER["SERVER_NAME"])) //! empty($_SERVER["SERVER_NAME"]) to be sure to enable this in Web mode only + { + try + { + // Warning FirePHPCore must be into PHP include path. It is not possible to use into require_once() a constant from + // database or config file because we must be able to log data before database or config file read. + $oldinclude=get_include_path(); + set_include_path('/usr/share/php/'); + include_once('FirePHPCore/FirePHP.class.php'); + set_include_path($oldinclude); + ob_start(); + $firephp = FirePHP::getInstance(true); + if ($level == LOG_ERR) $firephp->error($message); + elseif ($level == LOG_WARNING) $firephp->warn($message); + elseif ($level == LOG_INFO) $firephp->log($message); + else $firephp->log($message); + } + catch(Exception $e) + { + // Do not use dol_syslog to avoid infinite loop + } + } + } } @@ -598,7 +598,7 @@ function dol_syslog($message, $level=LOG_INFO) */ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='') { - print dol_get_fiche_head($links, $active, $title, $notab, $picto); + print dol_get_fiche_head($links, $active, $title, $notab, $picto); } /** @@ -613,60 +613,60 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto */ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='') { - $out="\n".'
'."\n"; + $out="\n".'
'."\n"; - // Affichage titre - if ($title) - { - $limittitle=30; - $out.=''; - if ($picto) $out.=img_object('',$picto).' '; - $out.=dol_trunc($title,$limittitle); - $out.=''; - } + // Affichage titre + if (! empty($title)) + { + $limittitle=30; + $out.=''; + if ($picto) $out.=img_object('',$picto).' '; + $out.=dol_trunc($title,$limittitle); + $out.=''; + } - // Define max of key (max may be higher than sizeof because of hole due to module disabling some tabs). - $maxkey=-1; - if (is_array($links)) - { - $keys=array_keys($links); - if (count($keys)) $maxkey=max($keys); - } + // Define max of key (max may be higher than sizeof because of hole due to module disabling some tabs). + $maxkey=-1; + if (is_array($links) && ! empty($links)) + { + $keys=array_keys($links); + if (count($keys)) $maxkey=max($keys); + } - // Show tabs - for ($i = 0 ; $i <= $maxkey ; $i++) - { - if (isset($links[$i][2]) && $links[$i][2] == 'image') - { - if (!empty($links[$i][0])) - { - $out.=''.$links[$i][1].''."\n"; - } - else - { - $out.=''.$links[$i][1].''."\n"; - } - } - else if (! empty($links[$i][1])) - { - //print "x $i $active ".$links[$i][2]." z"; - if ((is_numeric($active) && $i == $active) - || (! is_numeric($active) && $active == $links[$i][2])) - { - $out.=''.$links[$i][1].''."\n"; - } - else - { - $out.=''.$links[$i][1].''."\n"; - } - } - } + // Show tabs + for ($i = 0 ; $i <= $maxkey ; $i++) + { + if (isset($links[$i][2]) && $links[$i][2] == 'image') + { + if (!empty($links[$i][0])) + { + $out.=''.$links[$i][1].''."\n"; + } + else + { + $out.=''.$links[$i][1].''."\n"; + } + } + else if (! empty($links[$i][1])) + { + //print "x $i $active ".$links[$i][2]." z"; + if ((is_numeric($active) && $i == $active) + || (! is_numeric($active) && $active == $links[$i][2])) + { + $out.=''.$links[$i][1].''."\n"; + } + else + { + $out.=''.$links[$i][1].''."\n"; + } + } + } - $out.="
\n"; + $out.="
\n"; - if (! $notab) $out.="\n".'
'."\n"; + if (! $notab) $out.="\n".'
'."\n"; - return $out; + return $out; } /** @@ -677,7 +677,7 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p */ function dol_fiche_end($notab=0) { - print dol_get_fiche_end($notab); + print dol_get_fiche_end($notab); } /** @@ -688,8 +688,8 @@ function dol_fiche_end($notab=0) */ function dol_get_fiche_end($notab=0) { - if (! $notab) return "\n
\n"; - else return ''; + if (! $notab) return "\n
\n"; + else return ''; } /** @@ -750,131 +750,131 @@ function dol_format_address($object) */ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$encodetooutput=false) { - global $conf,$langs; + global $conf,$langs; - $to_gmt=false; - $offsettz=$offsetdst=0; - if ($tzoutput) - { - $to_gmt=true; // For backward compatibility - if (is_string($tzoutput)) - { - if ($tzoutput == 'tzserver') - { - $to_gmt=false; - $offsettz=$offsetdst=0; - } - elseif ($tzoutput == 'tzuser') - { - $to_gmt=true; - $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; - $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; - } - elseif ($tzoutput == 'tzcompany') - { - $to_gmt=false; - $offsettz=$offsetdst=0; // TODO Define this and use it later - } - } - } + $to_gmt=false; + $offsettz=$offsetdst=0; + if ($tzoutput) + { + $to_gmt=true; // For backward compatibility + if (is_string($tzoutput)) + { + if ($tzoutput == 'tzserver') + { + $to_gmt=false; + $offsettz=$offsetdst=0; + } + elseif ($tzoutput == 'tzuser') + { + $to_gmt=true; + $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; + $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; + } + elseif ($tzoutput == 'tzcompany') + { + $to_gmt=false; + $offsettz=$offsetdst=0; // TODO Define this and use it later + } + } + } - if (! is_object($outputlangs)) $outputlangs=$langs; + if (! is_object($outputlangs)) $outputlangs=$langs; - // Si format non defini, on prend $conf->format_date_text_short sinon %Y-%m-%d %H:%M:%S - if (! $format) $format=(isset($conf->format_date_text_short) ? $conf->format_date_text_short : '%Y-%m-%d %H:%M:%S'); + // Si format non defini, on prend $conf->format_date_text_short sinon %Y-%m-%d %H:%M:%S + if (! $format) $format=(isset($conf->format_date_text_short) ? $conf->format_date_text_short : '%Y-%m-%d %H:%M:%S'); - // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. - if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); - if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); - if ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration); - if ($format == 'daytext') $format=($outputlangs->trans("FormatDateText")!="FormatDateText"?$outputlangs->trans("FormatDateText"):$conf->format_date_text); - if ($format == 'daytextshort') $format=($outputlangs->trans("FormatDateTextShort")!="FormatDateTextShort"?$outputlangs->trans("FormatDateTextShort"):$conf->format_date_text_short); - if ($format == 'dayhour') $format=($outputlangs->trans("FormatDateHourShort")!="FormatDateHourShort"?$outputlangs->trans("FormatDateHourShort"):$conf->format_date_hour_short); - if ($format == 'dayhourtext') $format=($outputlangs->trans("FormatDateHourText")!="FormatDateHourText"?$outputlangs->trans("FormatDateHourText"):$conf->format_date_hour_text); - if ($format == 'dayhourtextshort') $format=($outputlangs->trans("FormatDateHourTextShort")!="FormatDateHourTextShort"?$outputlangs->trans("FormatDateHourTextShort"):$conf->format_date_hour_text_short); + // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. + if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); + if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); + if ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration); + if ($format == 'daytext') $format=($outputlangs->trans("FormatDateText")!="FormatDateText"?$outputlangs->trans("FormatDateText"):$conf->format_date_text); + if ($format == 'daytextshort') $format=($outputlangs->trans("FormatDateTextShort")!="FormatDateTextShort"?$outputlangs->trans("FormatDateTextShort"):$conf->format_date_text_short); + if ($format == 'dayhour') $format=($outputlangs->trans("FormatDateHourShort")!="FormatDateHourShort"?$outputlangs->trans("FormatDateHourShort"):$conf->format_date_hour_short); + if ($format == 'dayhourtext') $format=($outputlangs->trans("FormatDateHourText")!="FormatDateHourText"?$outputlangs->trans("FormatDateHourText"):$conf->format_date_hour_text); + if ($format == 'dayhourtextshort') $format=($outputlangs->trans("FormatDateHourTextShort")!="FormatDateHourTextShort"?$outputlangs->trans("FormatDateHourTextShort"):$conf->format_date_hour_text_short); - // Format not sensitive to language - if ($format == 'dayhourlog') $format='%Y%m%d%H%M%S'; - if ($format == 'dayhourldap') $format='%Y%m%d%H%M%SZ'; - if ($format == 'dayhourxcard') $format='%Y%m%dT%H%M%SZ'; - if ($format == 'dayxcard') $format='%Y%m%d'; - if ($format == 'dayrfc') $format='%Y-%m-%d'; // DATE_RFC3339 - if ($format == 'dayhourrfc') $format='%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 + // Format not sensitive to language + if ($format == 'dayhourlog') $format='%Y%m%d%H%M%S'; + if ($format == 'dayhourldap') $format='%Y%m%d%H%M%SZ'; + if ($format == 'dayhourxcard') $format='%Y%m%dT%H%M%SZ'; + if ($format == 'dayxcard') $format='%Y%m%d'; + if ($format == 'dayrfc') $format='%Y-%m-%d'; // DATE_RFC3339 + if ($format == 'dayhourrfc') $format='%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 - // If date undefined or "", we return "" - if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + // If date undefined or "", we return "" + if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) - //print 'x'.$time; + //print 'x'.$time; - if (preg_match('/%b/i',$format)) // There is some text to translate - { - // We inhibate translation to text made by strftime functions. We will use trans instead later. - $format=str_replace('%b','__b__',$format); - $format=str_replace('%B','__B__',$format); - } - if (preg_match('/%a/i',$format)) // There is some text to translate - { - // We inhibate translation to text made by strftime functions. We will use trans instead later. - $format=str_replace('%a','__a__',$format); - $format=str_replace('%A','__A__',$format); - } + if (preg_match('/%b/i',$format)) // There is some text to translate + { + // We inhibate translation to text made by strftime functions. We will use trans instead later. + $format=str_replace('%b','__b__',$format); + $format=str_replace('%B','__B__',$format); + } + if (preg_match('/%a/i',$format)) // There is some text to translate + { + // We inhibate translation to text made by strftime functions. We will use trans instead later. + $format=str_replace('%a','__a__',$format); + $format=str_replace('%A','__A__',$format); + } - // Analyze date (deprecated) Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$time,$reg) - || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i',$time,$reg)) - { - // This part of code should not be used. - dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); - // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' - $syear = (! empty($reg[1]) ? $reg[1] : ''); - $smonth = (! empty($reg[2]) ? $reg[2] : ''); - $sday = (! empty($reg[3]) ? $reg[3] : ''); - $shour = (! empty($reg[4]) ? $reg[4] : ''); - $smin = (! empty($reg[5]) ? $reg[5] : ''); - $ssec = (! empty($reg[6]) ? $reg[6] : ''); + // Analyze date (deprecated) Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$time,$reg) + || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i',$time,$reg)) + { + // This part of code should not be used. + dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); + // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' + $syear = (! empty($reg[1]) ? $reg[1] : ''); + $smonth = (! empty($reg[2]) ? $reg[2] : ''); + $sday = (! empty($reg[3]) ? $reg[3] : ''); + $shour = (! empty($reg[4]) ? $reg[4] : ''); + $smin = (! empty($reg[5]) ? $reg[5] : ''); + $ssec = (! empty($reg[6]) ? $reg[6] : ''); - $time=dol_mktime($shour,$smin,$ssec,$smonth,$sday,$syear,true); - $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); - } - else - { - // Date is a timestamps - if ($time < 100000000000) // Protection against bad date values - { - $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); - } - else $ret='Bad value '.$time.' for date'; - } + $time=dol_mktime($shour,$smin,$ssec,$smonth,$sday,$syear,true); + $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); + } + else + { + // Date is a timestamps + if ($time < 100000000000) // Protection against bad date values + { + $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); + } + else $ret='Bad value '.$time.' for date'; + } - if (preg_match('/__b__/i',$format)) - { - // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. - $month=adodb_strftime('%m',$time+$offsettz+$offsetdst); - if ($encodetooutput) - { - $monthtext=$outputlangs->transnoentities('Month'.$month); - $monthtextshort=$outputlangs->transnoentities('MonthShort'.$month); - } - else - { - $monthtext=$outputlangs->transnoentitiesnoconv('Month'.$month); - $monthtextshort=$outputlangs->transnoentitiesnoconv('MonthShort'.$month); - } - //print 'monthtext='.$monthtext.' monthtextshort='.$monthtextshort; - $ret=str_replace('__b__',$monthtextshort,$ret); - $ret=str_replace('__B__',$monthtext,$ret); - //print 'x'.$outputlangs->charset_output.'-'.$ret.'x'; - //return $ret; - } - if (preg_match('/__a__/i',$format)) - { - $w=adodb_strftime('%w',$time+$offsettz+$offsetdst); - $dayweek=$outputlangs->transnoentitiesnoconv('Day'.$w); - $ret=str_replace('__A__',$dayweek,$ret); - $ret=str_replace('__a__',dol_substr($dayweek,0,3),$ret); - } + if (preg_match('/__b__/i',$format)) + { + // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. + $month=adodb_strftime('%m',$time+$offsettz+$offsetdst); + if ($encodetooutput) + { + $monthtext=$outputlangs->transnoentities('Month'.$month); + $monthtextshort=$outputlangs->transnoentities('MonthShort'.$month); + } + else + { + $monthtext=$outputlangs->transnoentitiesnoconv('Month'.$month); + $monthtextshort=$outputlangs->transnoentitiesnoconv('MonthShort'.$month); + } + //print 'monthtext='.$monthtext.' monthtextshort='.$monthtextshort; + $ret=str_replace('__b__',$monthtextshort,$ret); + $ret=str_replace('__B__',$monthtext,$ret); + //print 'x'.$outputlangs->charset_output.'-'.$ret.'x'; + //return $ret; + } + if (preg_match('/__a__/i',$format)) + { + $w=adodb_strftime('%w',$time+$offsettz+$offsetdst); + $dayweek=$outputlangs->transnoentitiesnoconv('Day'.$w); + $ret=str_replace('__A__',$dayweek,$ret); + $ret=str_replace('__a__',dol_substr($dayweek,0,3),$ret); + } - return $ret; + return $ret; } @@ -912,20 +912,20 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e */ function dol_getdate($timestamp,$fast=false) { - $usealternatemethod=false; - if ($timestamp <= 0) $usealternatemethod=true; // <= 1970 - if ($timestamp >= 2145913200) $usealternatemethod=true; // >= 2038 + $usealternatemethod=false; + if ($timestamp <= 0) $usealternatemethod=true; // <= 1970 + if ($timestamp >= 2145913200) $usealternatemethod=true; // >= 2038 - if ($usealternatemethod) - { - $arrayinfo=adodb_getdate($timestamp,$fast); - } - else - { - $arrayinfo=getdate($timestamp); - } + if ($usealternatemethod) + { + $arrayinfo=adodb_getdate($timestamp,$fast); + } + else + { + $arrayinfo=getdate($timestamp); + } - return $arrayinfo; + return $arrayinfo; } /** @@ -946,50 +946,50 @@ function dol_getdate($timestamp,$fast=false) */ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) { - global $conf; - //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; + global $conf; + //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; - // Clean parameters - if ($hour == -1) $hour=0; - if ($minute == -1) $minute=0; - if ($second == -1) $second=0; + // Clean parameters + if ($hour == -1) $hour=0; + if ($minute == -1) $minute=0; + if ($second == -1) $second=0; - // Check parameters - if ($check) - { - if (! $month || ! $day) return ''; - if ($day > 31) return ''; - if ($month > 12) return ''; - if ($hour < 0 || $hour > 24) return ''; - if ($minute< 0 || $minute > 60) return ''; - if ($second< 0 || $second > 60) return ''; - } + // Check parameters + if ($check) + { + if (! $month || ! $day) return ''; + if ($day > 31) return ''; + if ($month > 12) return ''; + if ($hour < 0 || $hour > 24) return ''; + if ($minute< 0 || $minute > 60) return ''; + if ($second< 0 || $second > 60) return ''; + } - if (method_exists('DateTime','getTimestamp') && empty($conf->global->MAIN_OLD_DATE)) - { - if (empty($gm)) $localtz = new DateTimeZone(date_default_timezone_get()); - else $localtz = new DateTimeZone('UTC'); - $dt = new DateTime(null,$localtz); - $dt->setDate($year,$month,$day); - $dt->setTime((int) $hour, (int) $minute, (int) $second); - $date=$dt->getTimestamp(); - } - else - { - $usealternatemethod=false; - if ($year <= 1970) $usealternatemethod=true; // <= 1970 - if ($year >= 2038) $usealternatemethod=true; // >= 2038 + if (method_exists('DateTime','getTimestamp') && empty($conf->global->MAIN_OLD_DATE)) + { + if (empty($gm)) $localtz = new DateTimeZone(date_default_timezone_get()); + else $localtz = new DateTimeZone('UTC'); + $dt = new DateTime(null,$localtz); + $dt->setDate($year,$month,$day); + $dt->setTime((int) $hour, (int) $minute, (int) $second); + $date=$dt->getTimestamp(); + } + else + { + $usealternatemethod=false; + if ($year <= 1970) $usealternatemethod=true; // <= 1970 + if ($year >= 2038) $usealternatemethod=true; // >= 2038 - if ($usealternatemethod || $gm) // Si time gm, seule adodb peut convertir - { - $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,0,$gm); - } - else - { - $date=mktime($hour,$minute,$second,$month,$day,$year); - } - } - return $date; + if ($usealternatemethod || $gm) // Si time gm, seule adodb peut convertir + { + $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,0,$gm); + } + else + { + $date=mktime($hour,$minute,$second,$month,$day,$year); + } + } + return $date; } @@ -1004,29 +1004,29 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) */ function dol_now($mode='gmt') { - // Note that gmmktime and mktime return same value (GMT) whithout parameters + // Note that gmmktime and mktime return same value (GMT) whithout parameters //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead - if ($mode == 'gmt') $ret=time(); // Time for now at greenwich. - else if ($mode == 'tzserver') // Time for now with PHP server timezone added - { - require_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); - $tzsecond=getServerTimeZoneInt('now'); // Contains tz+dayling saving time - $ret=dol_now('gmt')+($tzsecond*3600); - } - /*else if ($mode == 'tzref') // Time for now with parent company timezone is added - { - require_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); - $tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time - $ret=dol_now('gmt')+($tzsecond*3600); - }*/ - else if ($mode == 'tzuser') // Time for now with user timezone is added - { - //print 'eeee'.time().'-'.mktime().'-'.gmmktime(); - $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; - $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; - $ret=dol_now('gmt')+($offsettz+$offsetdst); - } - return $ret; + if ($mode == 'gmt') $ret=time(); // Time for now at greenwich. + else if ($mode == 'tzserver') // Time for now with PHP server timezone added + { + require_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); + $tzsecond=getServerTimeZoneInt('now'); // Contains tz+dayling saving time + $ret=dol_now('gmt')+($tzsecond*3600); + } + /*else if ($mode == 'tzref') // Time for now with parent company timezone is added + { + require_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); + $tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time + $ret=dol_now('gmt')+($tzsecond*3600); + }*/ + else if ($mode == 'tzuser') // Time for now with user timezone is added + { + //print 'eeee'.time().'-'.mktime().'-'.gmmktime(); + $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; + $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; + $ret=dol_now('gmt')+($offsettz+$offsetdst); + } + return $ret; } @@ -1040,27 +1040,27 @@ function dol_now($mode='gmt') */ function dol_print_size($size,$shortvalue=0,$shortunit=0) { - global $langs; - $level=1024; + global $langs; + $level=1024; - // Set value text - if (empty($shortvalue) || $size < ($level*10)) - { - $ret=$size; - $textunitshort=$langs->trans("b"); - $textunitlong=$langs->trans("Bytes"); - } - else - { - $ret=round($size/$level,0); - $textunitshort=$langs->trans("Kb"); - $textunitlong=$langs->trans("KiloBytes"); - } - // Use long or short text unit - if (empty($shortunit)) { $ret.=' '.$textunitlong; } - else { $ret.=' '.$textunitshort; } + // Set value text + if (empty($shortvalue) || $size < ($level*10)) + { + $ret=$size; + $textunitshort=$langs->trans("b"); + $textunitlong=$langs->trans("Bytes"); + } + else + { + $ret=round($size/$level,0); + $textunitshort=$langs->trans("Kb"); + $textunitlong=$langs->trans("KiloBytes"); + } + // Use long or short text unit + if (empty($shortunit)) { $ret.=' '.$textunitlong; } + else { $ret.=' '.$textunitshort; } - return $ret; + return $ret; } /** @@ -1073,16 +1073,16 @@ function dol_print_size($size,$shortvalue=0,$shortunit=0) */ function dol_print_url($url,$target='_blank',$max=32) { - if (empty($url)) return ''; + if (empty($url)) return ''; - $link=''; - if (! preg_match('/^http/i',$url)) $link.='http://'; - $link.=dol_trunc($url,$max); - $link.=''; - return $link; + $link=''; + if (! preg_match('/^http/i',$url)) $link.='http://'; + $link.=dol_trunc($url,$max); + $link.=''; + return $link; } /** @@ -1098,42 +1098,42 @@ function dol_print_url($url,$target='_blank',$max=32) */ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid=1) { - global $conf,$user,$langs; + global $conf,$user,$langs; - $newemail=$email; + $newemail=$email; - if (empty($email)) return ' '; + if (empty($email)) return ' '; - if (! empty($addlink)) - { - $newemail=''; - $newemail.=dol_trunc($email,$max); - $newemail.=''; - if ($showinvalid && ! isValidEmail($email)) - { - $langs->load("errors"); - $newemail.=img_warning($langs->trans("ErrorBadEMail",$email)); - } + if (! empty($addlink)) + { + $newemail=''; + $newemail.=dol_trunc($email,$max); + $newemail.=''; + if ($showinvalid && ! isValidEmail($email)) + { + $langs->load("errors"); + $newemail.=img_warning($langs->trans("ErrorBadEMail",$email)); + } - if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create) - { - $type='AC_EMAIL'; $link=''; - if (! empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link=''.img_object($langs->trans("AddAction"),"calendar").''; - $newemail='
'.$newemail.'  '.$link.'
'; - } - } - else - { - if ($showinvalid && ! isValidEmail($email)) - { - $langs->load("errors"); - $newemail.=img_warning($langs->trans("ErrorBadEMail",$email)); - } - } - return $newemail; + if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create) + { + $type='AC_EMAIL'; $link=''; + if (! empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link=''.img_object($langs->trans("AddAction"),"calendar").''; + $newemail='
'.$newemail.'  '.$link.'
'; + } + } + else + { + if ($showinvalid && ! isValidEmail($email)) + { + $langs->load("errors"); + $newemail.=img_warning($langs->trans("ErrorBadEMail",$email)); + } + } + return $newemail; } /** @@ -1149,73 +1149,73 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid= */ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=" ") { - global $conf,$user,$langs; + global $conf,$user,$langs; - // Clean phone parameter - $phone = preg_replace("/[\s.-]/","",trim($phone)); - if (empty($phone)) { return ''; } + // Clean phone parameter + $phone = preg_replace("/[\s.-]/","",trim($phone)); + if (empty($phone)) { return ''; } - $newphone=$phone; - if (strtoupper($country) == "FR") - { - // France - if (dol_strlen($phone) == 10) { - $newphone=substr($newphone,0,2).$separ.substr($newphone,2,2).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2); - } - elseif (dol_strlen($newphone) == 7) - { - $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2); - } - elseif (dol_strlen($newphone) == 9) - { - $newphone=substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2); - } - elseif (dol_strlen($newphone) == 11) - { - $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); - } - elseif (dol_strlen($newphone) == 12) - { - $newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); - } - } + $newphone=$phone; + if (strtoupper($country) == "FR") + { + // France + if (dol_strlen($phone) == 10) { + $newphone=substr($newphone,0,2).$separ.substr($newphone,2,2).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2); + } + elseif (dol_strlen($newphone) == 7) + { + $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2); + } + elseif (dol_strlen($newphone) == 9) + { + $newphone=substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2); + } + elseif (dol_strlen($newphone) == 11) + { + $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); + } + elseif (dol_strlen($newphone) == 12) + { + $newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); + } + } - if (! empty($addlink)) - { - if (! empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') - { - if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial(); + if (! empty($addlink)) + { + if (! empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') + { + if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial(); - if (empty($conf->global->CLICKTODIAL_URL)) $urlmask='ErrorClickToDialModuleNotConfigured'; - else $urlmask=$conf->global->CLICKTODIAL_URL; - $clicktodial_poste=(! empty($user->clicktodial_poste)?urlencode($user->clicktodial_poste):''); - $clicktodial_login=(! empty($user->clicktodial_login)?urlencode($user->clicktodial_login):''); - $clicktodial_password=(! empty($user->clicktodial_password)?urlencode($user->clicktodial_password):''); - // This line is for backward compatibility - $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password); - // Thoose lines are for substitution - $substitarray=array('__PHONEFROM__'=>$clicktodial_poste, - '__PHONETO__'=>urlencode($phone), - '__LOGIN__'=>$clicktodial_login, - '__PASS__'=>$clicktodial_password); - $url = make_substitutions($url, $substitarray); - $newphonesav=$newphone; - $newphone ='global->CLICKTODIAL_FORCENEWTARGET)) $newphone.=' target="_blank"'; - $newphone.='>'.$newphonesav.''; - } + if (empty($conf->global->CLICKTODIAL_URL)) $urlmask='ErrorClickToDialModuleNotConfigured'; + else $urlmask=$conf->global->CLICKTODIAL_URL; + $clicktodial_poste=(! empty($user->clicktodial_poste)?urlencode($user->clicktodial_poste):''); + $clicktodial_login=(! empty($user->clicktodial_login)?urlencode($user->clicktodial_login):''); + $clicktodial_password=(! empty($user->clicktodial_password)?urlencode($user->clicktodial_password):''); + // This line is for backward compatibility + $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password); + // Thoose lines are for substitution + $substitarray=array('__PHONEFROM__'=>$clicktodial_poste, + '__PHONETO__'=>urlencode($phone), + '__LOGIN__'=>$clicktodial_login, + '__PASS__'=>$clicktodial_password); + $url = make_substitutions($url, $substitarray); + $newphonesav=$newphone; + $newphone ='global->CLICKTODIAL_FORCENEWTARGET)) $newphone.=' target="_blank"'; + $newphone.='>'.$newphonesav.''; + } - //if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create) - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) - { - $type='AC_TEL'; $link=''; - if ($addlink == 'AC_FAX') $type='AC_FAX'; - if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link=''.img_object($langs->trans("AddAction"),"calendar").''; - $newphone='
'.$newphone.'  '.$link.'
'; - } - } + //if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create) + if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + { + $type='AC_TEL'; $link=''; + if ($addlink == 'AC_FAX') $type='AC_FAX'; + if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link=''.img_object($langs->trans("AddAction"),"calendar").''; + $newphone='
'.$newphone.'  '.$link.'
'; + } + } - return $newphone; + return $newphone; } /** @@ -1227,34 +1227,34 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ= */ function dol_print_ip($ip,$mode=0) { - global $conf,$langs; + global $conf,$langs; - $ret=''; + $ret=''; - if (empty($mode)) $ret.=$ip; + if (empty($mode)) $ret.=$ip; - if (! empty($conf->geoipmaxmind->enabled) && $mode != 2) - { - $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; - //$ip='24.24.24.24'; - //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages) + if (! empty($conf->geoipmaxmind->enabled) && $mode != 2) + { + $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; + //$ip='24.24.24.24'; + //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages) - include_once(DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'); - $geoip=new DolGeoIP('country',$datafile); - //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n"; - //print "geoip_country_id_by_addr=".geoip_country_id_by_addr($geoip->gi,$ip)."\n"; - $countrycode=$geoip->getCountryCodeFromIP($ip); - if ($countrycode) // If success, countrycode is us, fr, ... - { - if (file_exists(DOL_DOCUMENT_ROOT.'/theme/common/flags/'.$countrycode.'.png')) - { - $ret.=' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"),DOL_URL_ROOT.'/theme/common/flags/'.$countrycode.'.png','',1); - } - else $ret.=' ('.$countrycode.')'; - } - } + include_once(DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'); + $geoip=new DolGeoIP('country',$datafile); + //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n"; + //print "geoip_country_id_by_addr=".geoip_country_id_by_addr($geoip->gi,$ip)."\n"; + $countrycode=$geoip->getCountryCodeFromIP($ip); + if ($countrycode) // If success, countrycode is us, fr, ... + { + if (file_exists(DOL_DOCUMENT_ROOT.'/theme/common/flags/'.$countrycode.'.png')) + { + $ret.=' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"),DOL_URL_ROOT.'/theme/common/flags/'.$countrycode.'.png','',1); + } + else $ret.=' ('.$countrycode.')'; + } + } - return $ret; + return $ret; } /** @@ -1265,22 +1265,22 @@ function dol_print_ip($ip,$mode=0) */ function dol_user_country() { - global $conf,$langs,$user; + global $conf,$langs,$user; - //$ret=$user->xxx; - $ret=''; - if (! empty($conf->geoipmaxmind->enabled)) - { - $ip=$_SERVER["REMOTE_ADDR"]; - $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; - //$ip='24.24.24.24'; - //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; - include_once(DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'); - $geoip=new DolGeoIP('country',$datafile); - $countrycode=$geoip->getCountryCodeFromIP($ip); - $ret=$countrycode; - } - return $ret; + //$ret=$user->xxx; + $ret=''; + if (! empty($conf->geoipmaxmind->enabled)) + { + $ip=$_SERVER["REMOTE_ADDR"]; + $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; + //$ip='24.24.24.24'; + //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; + include_once(DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'); + $geoip=new DolGeoIP('country',$datafile); + $countrycode=$geoip->getCountryCodeFromIP($ip); + $ret=$countrycode; + } + return $ret; } /** @@ -1294,31 +1294,31 @@ function dol_user_country() */ function dol_print_address($address, $htmlid, $mode, $id) { - global $conf,$user,$langs; + global $conf,$user,$langs; - if ($address) - { - print nl2br($address); - $showgmap=$showomap=0; - if ($mode=='thirdparty' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; - if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap=1; - if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap=1; - if ($mode=='thirdparty' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; - if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap=1; - if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap=1; + if ($address) + { + print nl2br($address); + $showgmap=$showomap=0; + if ($mode=='thirdparty' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; + if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap=1; + if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap=1; + if ($mode=='thirdparty' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; + if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap=1; + if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap=1; - // TODO Add a hook here - if ($showgmap) - { - $url=dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id,1); - print ' '; - } - if ($showomap) - { - $url=dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id,1); - print ' '; - } - } + // TODO Add a hook here + if ($showgmap) + { + $url=dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id,1); + print ' '; + } + if ($showomap) + { + $url=dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id,1); + print ' '; + } + } } @@ -1330,19 +1330,19 @@ function dol_print_address($address, $htmlid, $mode, $id) */ function isValidEmail($address) { - if (preg_match("/.*<(.+)>/i", $address, $regs)) { - $address = $regs[1]; - } - // 2 letters domains extensions are for countries - // 3 letters domains extensions: biz|com|edu|gov|int|mil|net|org|pro|... - if (preg_match("/^[^@\s\t]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2,3}|asso|aero|coop|info|name)\$/i",$address)) - { - return true; - } - else - { - return false; - } + if (preg_match("/.*<(.+)>/i", $address, $regs)) { + $address = $regs[1]; + } + // 2 letters domains extensions are for countries + // 3 letters domains extensions: biz|com|edu|gov|int|mil|net|org|pro|... + if (preg_match("/^[^@\s\t]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2,3}|asso|aero|coop|info|name)\$/i",$address)) + { + return true; + } + else + { + return false; + } } /** @@ -1353,7 +1353,7 @@ function isValidEmail($address) */ function isValidPhone($phone) { - return true; + return true; } @@ -1366,8 +1366,8 @@ function isValidPhone($phone) */ function dol_strlen($string,$stringencoding='UTF-8') { - if (function_exists('mb_strlen')) return mb_strlen($string,$stringencoding); - else return strlen($string); + if (function_exists('mb_strlen')) return mb_strlen($string,$stringencoding); + else return strlen($string); } /** @@ -1381,20 +1381,20 @@ function dol_strlen($string,$stringencoding='UTF-8') */ function dol_substr($string,$start,$length,$stringencoding='') { - global $langs; + global $langs; - if (empty($stringencoding)) $stringencoding=$langs->charset_output; + if (empty($stringencoding)) $stringencoding=$langs->charset_output; - $ret=''; - if (function_exists('mb_substr')) - { - $ret=mb_substr($string,$start,$length,$stringencoding); - } - else - { - $ret=substr($string,$start,$length); - } - return $ret; + $ret=''; + if (function_exists('mb_substr')) + { + $ret=mb_substr($string,$start,$length,$stringencoding); + } + else + { + $ret=substr($string,$start,$length); + } + return $ret; } @@ -1573,48 +1573,48 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie', */ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0) { - global $conf; + global $conf; - if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; + if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; - // We go always here - if ($trunc == 'right') - { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; - if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:1))) - return dol_substr($newstring,0,$size,$stringencoding).($nodot?'':'...'); - else - return $string; - } - elseif ($trunc == 'middle') - { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; - if (dol_strlen($newstring,$stringencoding) > 2 && dol_strlen($newstring,$stringencoding) > ($size+1)) - { - $size1=round($size/2); - $size2=round($size/2); - return dol_substr($newstring,0,$size1,$stringencoding).'...'.dol_substr($newstring,dol_strlen($newstring,$stringencoding) - $size2,$size2,$stringencoding); - } - else - return $string; - } - elseif ($trunc == 'left') - { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; - if (dol_strlen($newstring,$stringencoding) > ($size+1)) - return '...'.dol_substr($newstring,dol_strlen($newstring,$stringencoding) - $size,$size,$stringencoding); - else - return $string; - } - elseif ($trunc == 'wrap') - { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; - if (dol_strlen($newstring,$stringencoding) > ($size+1)) - return dol_substr($newstring,0,$size,$stringencoding)."\n".dol_trunc(dol_substr($newstring,$size,dol_strlen($newstring,$stringencoding)-$size,$stringencoding),$size,$trunc); - else - return $string; - } - else return 'BadParam3CallingDolTrunc'; + // We go always here + if ($trunc == 'right') + { + $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; + if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:1))) + return dol_substr($newstring,0,$size,$stringencoding).($nodot?'':'...'); + else + return $string; + } + elseif ($trunc == 'middle') + { + $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; + if (dol_strlen($newstring,$stringencoding) > 2 && dol_strlen($newstring,$stringencoding) > ($size+1)) + { + $size1=round($size/2); + $size2=round($size/2); + return dol_substr($newstring,0,$size1,$stringencoding).'...'.dol_substr($newstring,dol_strlen($newstring,$stringencoding) - $size2,$size2,$stringencoding); + } + else + return $string; + } + elseif ($trunc == 'left') + { + $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; + if (dol_strlen($newstring,$stringencoding) > ($size+1)) + return '...'.dol_substr($newstring,dol_strlen($newstring,$stringencoding) - $size,$size,$stringencoding); + else + return $string; + } + elseif ($trunc == 'wrap') + { + $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; + if (dol_strlen($newstring,$stringencoding) > ($size+1)) + return dol_substr($newstring,0,$size,$stringencoding)."\n".dol_trunc(dol_substr($newstring,$size,dol_strlen($newstring,$stringencoding)-$size,$stringencoding),$size,$trunc); + else + return $string; + } + else return 'BadParam3CallingDolTrunc'; } @@ -1631,29 +1631,29 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo */ function img_object($alt, $picto, $options='', $pictoisfullpath=0) { - global $conf; + global $conf; - // Clean parameters - if (! preg_match('/(\.png|\.gif)$/i',$picto) && ! preg_match('/^([^@]+)@([^@]+)$/i',$picto)) $picto.='.png'; + // Clean parameters + if (! preg_match('/(\.png|\.gif)$/i',$picto) && ! preg_match('/^([^@]+)@([^@]+)$/i',$picto)) $picto.='.png'; - // Define fullpathpicto to use into src - if (! empty($pictoisfullpath)) $fullpathpicto=$picto; - else - { - // By default, we search into theme directory - $url = DOL_URL_ROOT; - $path = 'theme/'.$conf->theme; - if (! empty($conf->global->MAIN_FORCETHEMEDIR)) $path=preg_replace('/^\//','',$conf->global->MAIN_FORCETHEMEDIR).'/'.$path; - // If we ask an image into module/img (not into a theme path) - if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { $picto = $regs[1]; $path=$regs[2]; } // If image into a module/img path - if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto.='.png'; - // If img file not into standard path, we use alternate path - if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/object_'.$picto)) $url = DOL_URL_ROOT_ALT; + // Define fullpathpicto to use into src + if (! empty($pictoisfullpath)) $fullpathpicto=$picto; + else + { + // By default, we search into theme directory + $url = DOL_URL_ROOT; + $path = 'theme/'.$conf->theme; + if (! empty($conf->global->MAIN_FORCETHEMEDIR)) $path=preg_replace('/^\//','',$conf->global->MAIN_FORCETHEMEDIR).'/'.$path; + // If we ask an image into module/img (not into a theme path) + if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { $picto = $regs[1]; $path=$regs[2]; } // If image into a module/img path + if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto.='.png'; + // If img file not into standard path, we use alternate path + if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/object_'.$picto)) $url = DOL_URL_ROOT_ALT; - $fullpathpicto=$url.'/'.$path.'/img/object_'.$picto; - } + $fullpathpicto=$url.'/'.$path.'/img/object_'.$picto; + } - return ''.dol_escape_htmltag($alt).''; + return ''.dol_escape_htmltag($alt).''; } /** @@ -1672,29 +1672,29 @@ function img_object($alt, $picto, $options='', $pictoisfullpath=0) */ function img_picto($alt, $picto, $options='', $pictoisfullpath=0) { - global $conf; + global $conf; - // Clean parameters - if (! preg_match('/(\.png|\.gif)$/i',$picto) && ! preg_match('/^([^@]+)@([^@]+)$/i',$picto)) $picto.='.png'; + // Clean parameters + if (! preg_match('/(\.png|\.gif)$/i',$picto) && ! preg_match('/^([^@]+)@([^@]+)$/i',$picto)) $picto.='.png'; - // Define fullpathpicto to use into src - if (! empty($pictoisfullpath)) $fullpathpicto=$picto; - else - { - // By default, we search into theme directory - $url = DOL_URL_ROOT; - $path = 'theme/'.$conf->theme; - if (! empty($conf->global->MAIN_FORCETHEMEDIR)) $path=preg_replace('/^\//','',$conf->global->MAIN_FORCETHEMEDIR).'/'.$path; - // If we ask an image into module/img (not into a theme path) - if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { $picto = $regs[1]; $path=$regs[2]; } // If image into a module/img path - if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto.='.png'; - // If img file not into standard path, we use alternate path - if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/'.$picto)) $url = DOL_URL_ROOT_ALT; + // Define fullpathpicto to use into src + if (! empty($pictoisfullpath)) $fullpathpicto=$picto; + else + { + // By default, we search into theme directory + $url = DOL_URL_ROOT; + $path = 'theme/'.$conf->theme; + if (! empty($conf->global->MAIN_FORCETHEMEDIR)) $path=preg_replace('/^\//','',$conf->global->MAIN_FORCETHEMEDIR).'/'.$path; + // If we ask an image into module/img (not into a theme path) + if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { $picto = $regs[1]; $path=$regs[2]; } // If image into a module/img path + if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto.='.png'; + // If img file not into standard path, we use alternate path + if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/'.$picto)) $url = DOL_URL_ROOT_ALT; - $fullpathpicto=$url.'/'.$path.'/img/'.$picto; - } + $fullpathpicto=$url.'/'.$path.'/img/'.$picto; + } - return ''.dol_escape_htmltag($alt).''; + return ''.dol_escape_htmltag($alt).''; } /** @@ -1709,24 +1709,24 @@ function img_picto($alt, $picto, $options='', $pictoisfullpath=0) */ function img_picto_common($alt, $picto, $options = '', $pictoisfullpath = 0) { - global $conf; + global $conf; - if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; + if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; - if ($pictoisfullpath) $path = $picto; - else - { - $path = DOL_URL_ROOT.'/theme/common/'.$picto; - - if (! empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) - { - $themepath = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto; + if ($pictoisfullpath) $path = $picto; + else + { + $path = DOL_URL_ROOT.'/theme/common/'.$picto; + + if (! empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) + { + $themepath = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto; - if (file_exists($themepath)) return img_picto($alt, $themepath, $options, 1); - } - } + if (file_exists($themepath)) return img_picto($alt, $themepath, $options, 1); + } + } - return img_picto($alt, $path, $options, 1); + return img_picto($alt, $path, $options, 1); } /** @@ -1738,18 +1738,18 @@ function img_picto_common($alt, $picto, $options = '', $pictoisfullpath = 0) */ function img_action($alt, $numaction) { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') - { - if ($numaction == -1) $alt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); - if ($numaction == 0) $alt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); - if ($numaction == 1) $alt = $langs->transnoentitiesnoconv('ChangeToContact'); - if ($numaction == 2) $alt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); - if ($numaction == 3) $alt = $langs->transnoentitiesnoconv('ChangeContactDone'); - } + if ($alt == 'default') + { + if ($numaction == -1) $alt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); + if ($numaction == 0) $alt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); + if ($numaction == 1) $alt = $langs->transnoentitiesnoconv('ChangeToContact'); + if ($numaction == 2) $alt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); + if ($numaction == 3) $alt = $langs->transnoentitiesnoconv('ChangeContactDone'); + } - return img_picto($alt, 'stcomm'.$numaction.'.png'); + return img_picto($alt, 'stcomm'.$numaction.'.png'); } /** @@ -1761,11 +1761,11 @@ function img_action($alt, $numaction) */ function img_pdf($alt = 'default', $size = 3) { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Show'); + if ($alt == 'default') $alt = $langs->trans('Show'); - return img_picto($alt, 'pdf'.$size.'.png'); + return img_picto($alt, 'pdf'.$size.'.png'); } /** @@ -1776,11 +1776,11 @@ function img_pdf($alt = 'default', $size = 3) */ function img_edit_add($alt = 'default') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Add'); + if ($alt == 'default') $alt = $langs->trans('Add'); - return img_picto($alt, 'edit_add.png'); + return img_picto($alt, 'edit_add.png'); } /** * Show logo - @@ -1790,11 +1790,11 @@ function img_edit_add($alt = 'default') */ function img_edit_remove($alt = 'default') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Remove'); + if ($alt == 'default') $alt = $langs->trans('Remove'); - return img_picto($alt, 'edit_remove.png'); + return img_picto($alt, 'edit_remove.png'); } /** @@ -1807,11 +1807,11 @@ function img_edit_remove($alt = 'default') */ function img_edit($alt = 'default', $float = 0, $other = '') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Modify'); + if ($alt == 'default') $alt = $langs->trans('Modify'); - return img_picto($alt, 'edit.png', ($float ? 'style="float: right"' : $other)); + return img_picto($alt, 'edit.png', ($float ? 'style="float: right"' : $other)); } /** @@ -1824,13 +1824,13 @@ function img_edit($alt = 'default', $float = 0, $other = '') */ function img_view($alt = 'default', $float = 0, $other = '') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('View'); + if ($alt == 'default') $alt = $langs->trans('View'); - $options = ($float ? 'style="float: right" ' : '').$other; - - return img_picto($alt, 'view.png', $options); + $options = ($float ? 'style="float: right" ' : '').$other; + + return img_picto($alt, 'view.png', $options); } /** @@ -1842,11 +1842,11 @@ function img_view($alt = 'default', $float = 0, $other = '') */ function img_delete($alt = 'default', $other = '') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Delete'); + if ($alt == 'default') $alt = $langs->trans('Delete'); - return img_picto($alt, 'delete.png', $other); + return img_picto($alt, 'delete.png', $other); } /** @@ -1858,15 +1858,15 @@ function img_delete($alt = 'default', $other = '') */ function img_help($usehelpcursor = 1, $usealttitle = 1) { - global $conf, $langs; + global $conf, $langs; - if ($usealttitle) - { - if (is_string($usealttitle)) $alt = dol_escape_htmltag($usealttitle); - else $alt = $langs->trans('Info'); - } + if ($usealttitle) + { + if (is_string($usealttitle)) $alt = dol_escape_htmltag($usealttitle); + else $alt = $langs->trans('Info'); + } - return img_picto($usealttitle, 'info.png', ($usehelpcursor ? 'style="cursor: help"' : '')); + return img_picto($usealttitle, 'info.png', ($usehelpcursor ? 'style="cursor: help"' : '')); } /** @@ -1877,11 +1877,11 @@ function img_help($usehelpcursor = 1, $usealttitle = 1) */ function img_info($alt = 'default') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Informations'); + if ($alt == 'default') $alt = $langs->trans('Informations'); - return img_picto($alt, 'info.png'); + return img_picto($alt, 'info.png'); } /** @@ -1893,11 +1893,11 @@ function img_info($alt = 'default') */ function img_warning($alt = 'default', $float = 0) { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Warning'); + if ($alt == 'default') $alt = $langs->trans('Warning'); - return img_picto($alt, 'warning.png', ($float ? 'style="float: right"' : '')); + return img_picto($alt, 'warning.png', ($float ? 'style="float: right"' : '')); } /** @@ -1908,11 +1908,11 @@ function img_warning($alt = 'default', $float = 0) */ function img_error($alt = 'default') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Error'); + if ($alt == 'default') $alt = $langs->trans('Error'); - return img_picto($alt, 'error.png'); + return img_picto($alt, 'error.png'); } /** @@ -1923,11 +1923,11 @@ function img_error($alt = 'default') */ function img_next($alt = 'default') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Next'); + if ($alt == 'default') $alt = $langs->trans('Next'); - return img_picto($alt, 'next.png'); + return img_picto($alt, 'next.png'); } /** @@ -1938,11 +1938,11 @@ function img_next($alt = 'default') */ function img_previous($alt = 'default') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Previous'); + if ($alt == 'default') $alt = $langs->trans('Previous'); - return img_picto($alt, 'previous.png'); + return img_picto($alt, 'previous.png'); } /** @@ -1954,11 +1954,11 @@ function img_previous($alt = 'default') */ function img_down($alt = 'default', $selected = 0) { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Down'); + if ($alt == 'default') $alt = $langs->trans('Down'); - return img_picto($alt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown"'); + return img_picto($alt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown"'); } /** @@ -1970,11 +1970,11 @@ function img_down($alt = 'default', $selected = 0) */ function img_up($alt = 'default', $selected = 0) { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Up'); + if ($alt == 'default') $alt = $langs->trans('Up'); - return img_picto($alt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup"'); + return img_picto($alt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup"'); } /** @@ -1986,11 +1986,11 @@ function img_up($alt = 'default', $selected = 0) */ function img_left($alt = 'default', $selected = 0) { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Left'); + if ($alt == 'default') $alt = $langs->trans('Left'); - return img_picto($alt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png')); + return img_picto($alt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png')); } /** @@ -2002,11 +2002,11 @@ function img_left($alt = 'default', $selected = 0) */ function img_right($alt = 'default', $selected = 0) { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Right'); + if ($alt == 'default') $alt = $langs->trans('Right'); - return img_picto($alt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png')); + return img_picto($alt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png')); } /** @@ -2018,13 +2018,13 @@ function img_right($alt = 'default', $selected = 0) */ function img_allow($allow, $alt = 'default') { - global $conf, $langs; + global $conf, $langs; - if ($alt == 'default') $alt = $langs->trans('Active'); + if ($alt == 'default') $alt = $langs->trans('Active'); - if ($allow == 1) return img_picto($alt, 'tick.png'); - - return '-'; + if ($allow == 1) return img_picto($alt, 'tick.png'); + + return '-'; } @@ -2037,14 +2037,14 @@ function img_allow($allow, $alt = 'default') */ function img_mime($file, $alt = '') { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $mimetype = dol_mimetype($file, '', 1); - $mimeimg = dol_mimetype($file, '', 2); + $mimetype = dol_mimetype($file, '', 1); + $mimeimg = dol_mimetype($file, '', 2); - if (empty($alt)) $alt = 'Mime type: '.$mimetype; + if (empty($alt)) $alt = 'Mime type: '.$mimetype; - return img_picto_common($alt, 'mime/'.$mimeimg); + return img_picto_common($alt, 'mime/'.$mimeimg); } @@ -2079,14 +2079,14 @@ function img_phone($alt = 'default', $option = 0) */ function info_admin($text, $infoonimgalt = 0) { - global $conf, $langs; + global $conf, $langs; - if ($infoonimgalt) - { - return img_picto($text, 'star'); - } - - return '
'.img_picto($langs->trans('InfoAdmin'), 'star').' '.$text.'
'; + if ($infoonimgalt) + { + return img_picto($text, 'star'); + } + + return '
'.img_picto($langs->trans('InfoAdmin'), 'star').' '.$text.'
'; } @@ -2103,109 +2103,109 @@ function info_admin($text, $infoonimgalt = 0) */ function dol_print_error($db='',$error='') { - global $conf,$langs,$argv; - global $dolibarr_main_prod; + global $conf,$langs,$argv; + global $dolibarr_main_prod; - $out = ''; - $syslog = ''; + $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"); + // 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']) // Mode web - { - $out.=$langs->trans("DolibarrHasDetectedError").".
\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.
\n"; - $out.=$langs->trans("InformationToHelpDiagnose").":
\n"; + if ($_SERVER['DOCUMENT_ROOT']) // Mode web + { + $out.=$langs->trans("DolibarrHasDetectedError").".
\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.
\n"; + $out.=$langs->trans("InformationToHelpDiagnose").":
\n"; - $out.="".$langs->trans("Date").": ".dol_print_date(time(),'dayhourlog')."
\n";; - $out.="".$langs->trans("Dolibarr").": ".DOL_VERSION."
\n";; - if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="".$langs->trans("LevelOfFeature").": ".$conf->global->MAIN_FEATURES_LEVEL."
\n";; - if (function_exists("phpversion")) - { - $out.="".$langs->trans("PHP").": ".phpversion()."
\n"; - //phpinfo(); // This is to show location of php.ini file - } - $out.="".$langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."
\n";; - $out.="
\n"; - $out.="".$langs->trans("RequestedUrl").": ".$_SERVER["REQUEST_URI"]."
\n";; - $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:'')."
\n";; - $out.="".$langs->trans("MenuManager").": ".$conf->top_menu."
\n"; - $out.="
\n"; - $syslog.="url=".$_SERVER["REQUEST_URI"]; - $syslog.=", query_string=".$_SERVER["QUERY_STRING"]; - } - else // Mode CLI - { - $out.='> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; - $syslog.="pid=".getmypid(); - } + $out.="".$langs->trans("Date").": ".dol_print_date(time(),'dayhourlog')."
\n";; + $out.="".$langs->trans("Dolibarr").": ".DOL_VERSION."
\n";; + if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="".$langs->trans("LevelOfFeature").": ".$conf->global->MAIN_FEATURES_LEVEL."
\n";; + if (function_exists("phpversion")) + { + $out.="".$langs->trans("PHP").": ".phpversion()."
\n"; + //phpinfo(); // This is to show location of php.ini file + } + $out.="".$langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."
\n";; + $out.="
\n"; + $out.="".$langs->trans("RequestedUrl").": ".$_SERVER["REQUEST_URI"]."
\n";; + $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:'')."
\n";; + $out.="".$langs->trans("MenuManager").": ".$conf->top_menu."
\n"; + $out.="
\n"; + $syslog.="url=".$_SERVER["REQUEST_URI"]; + $syslog.=", query_string=".$_SERVER["QUERY_STRING"]; + } + else // Mode CLI + { + $out.='> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; + $syslog.="pid=".getmypid(); + } - if (is_object($db)) - { - if ($_SERVER['DOCUMENT_ROOT']) // Mode web - { - $out.="".$langs->trans("DatabaseTypeManager").": ".$db->type."
\n"; - $out.="".$langs->trans("RequestLastAccessInError").": ".($db->lastqueryerror()?$db->lastqueryerror():$langs->trans("ErrorNoRequestInError"))."
\n"; - $out.="".$langs->trans("ReturnCodeLastAccessInError").": ".($db->lasterrno()?$db->lasterrno():$langs->trans("ErrorNoRequestInError"))."
\n"; - $out.="".$langs->trans("InformationLastAccessInError").": ".($db->lasterror()?$db->lasterror():$langs->trans("ErrorNoRequestInError"))."
\n"; - $out.="
\n"; - } - else // Mode CLI - { - $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"; + if (is_object($db)) + { + if ($_SERVER['DOCUMENT_ROOT']) // Mode web + { + $out.="".$langs->trans("DatabaseTypeManager").": ".$db->type."
\n"; + $out.="".$langs->trans("RequestLastAccessInError").": ".($db->lastqueryerror()?$db->lastqueryerror():$langs->trans("ErrorNoRequestInError"))."
\n"; + $out.="".$langs->trans("ReturnCodeLastAccessInError").": ".($db->lasterrno()?$db->lasterrno():$langs->trans("ErrorNoRequestInError"))."
\n"; + $out.="".$langs->trans("InformationLastAccessInError").": ".($db->lasterror()?$db->lasterror():$langs->trans("ErrorNoRequestInError"))."
\n"; + $out.="
\n"; + } + else // Mode CLI + { + $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(); - } + } + $syslog.=", sql=".$db->lastquery(); + $syslog.=", db_error=".$db->lasterror(); + } - if ($error) - { - $langs->load("errors"); + if ($error) + { + $langs->load("errors"); - if (is_array($error)) $errors=$error; - else $errors=array($error); + if (is_array($error)) $errors=$error; + else $errors=array($error); - foreach($errors as $msg) - { - $msg=$langs->trans($msg); - if ($_SERVER['DOCUMENT_ROOT']) // Mode web - { - $out.="".$langs->trans("Message").": ".$msg."
\n" ; - } - else // Mode CLI - { - $out.='> '.$langs->transnoentities("Message").":\n".$msg."\n" ; - } - $syslog.=", msg=".$msg; - } - } - if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_print_function_stack') && function_exists('xdebug_call_file')) - { - xdebug_print_function_stack(); - $out.='XDebug informations:'."
\n"; - $out.='File: '.xdebug_call_file()."
\n"; - $out.='Line: '.xdebug_call_line()."
\n"; - $out.='Function: '.xdebug_call_function()."
\n"; - $out.="
\n"; - } + foreach($errors as $msg) + { + $msg=$langs->trans($msg); + if ($_SERVER['DOCUMENT_ROOT']) // Mode web + { + $out.="".$langs->trans("Message").": ".$msg."
\n" ; + } + else // Mode CLI + { + $out.='> '.$langs->transnoentities("Message").":\n".$msg."\n" ; + } + $syslog.=", msg=".$msg; + } + } + if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_print_function_stack') && function_exists('xdebug_call_file')) + { + xdebug_print_function_stack(); + $out.='XDebug informations:'."
\n"; + $out.='File: '.xdebug_call_file()."
\n"; + $out.='Line: '.xdebug_call_line()."
\n"; + $out.='Function: '.xdebug_call_function()."
\n"; + $out.="
\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); + 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); } /** @@ -2215,11 +2215,11 @@ function dol_print_error($db='',$error='') */ function dol_print_error_email() { - global $langs,$conf; + global $langs,$conf; - $langs->load("errors"); - $now=dol_now(); - print '
'.$langs->trans("ErrorContactEMail",$conf->global->MAIN_INFO_SOCIETE_MAIL,'ERRORNEWPAYMENT'.dol_print_date($now,'%Y%m%d')).'
'; + $langs->load("errors"); + $now=dol_now(); + print '
'.$langs->trans("ErrorContactEMail",$conf->global->MAIN_INFO_SOCIETE_MAIL,'ERRORNEWPAYMENT'.dol_print_date($now,'%Y%m%d')).'
'; } /** @@ -2256,59 +2256,59 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar */ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="") { - global $conf; - //print "$name, $file, $field, $begin, $options, $moreattrib, $sortfield, $sortorder
\n"; + global $conf; + //print "$name, $file, $field, $begin, $options, $moreattrib, $sortfield, $sortorder
\n"; - $out=''; + $out=''; // If field is used as sort criteria we use a specific class - // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") - if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) - { - $out.= ''; - } - else - { - $out.= ''; - } - $out.=$name; + // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") + if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) + { + $out.= ''; + } + else + { + $out.= ''; + } + $out.=$name; - if (empty($thead) && $field) // If this is a sort field - { - $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i','',$moreparam); - $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i','',$options); - $options=preg_replace('/&+/i','&',$options); - if (! preg_match('/^&/',$options)) $options='&'.$options; + if (empty($thead) && $field) // If this is a sort field + { + $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i','',$moreparam); + $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i','',$options); + $options=preg_replace('/&+/i','&',$options); + if (! preg_match('/^&/',$options)) $options='&'.$options; - //print " "; - $out.= ''; - if (! $sortorder) - { - $out.= ''.img_down("A-Z",0).''; - $out.= ''.img_up("Z-A",0).''; - } - else - { - if ($field != $sortfield) - { - $out.= ''.img_down("A-Z",0).''; - $out.= ''.img_up("Z-A",0).''; - } - else { - $sortorder=strtoupper($sortorder); - if ($sortorder == 'DESC' ) { - $out.= ''.img_down("A-Z",0).''; - $out.= ''.img_up("Z-A",1).''; - } - if ($sortorder == 'ASC' ) { - $out.= ''.img_down("A-Z",1).''; - $out.= ''.img_up("Z-A",0).''; - } - } - } - } - $out.=''; + //print " "; + $out.= ''; + if (! $sortorder) + { + $out.= ''.img_down("A-Z",0).''; + $out.= ''.img_up("Z-A",0).''; + } + else + { + if ($field != $sortfield) + { + $out.= ''.img_down("A-Z",0).''; + $out.= ''.img_up("Z-A",0).''; + } + else { + $sortorder=strtoupper($sortorder); + if ($sortorder == 'DESC' ) { + $out.= ''.img_down("A-Z",0).''; + $out.= ''.img_up("Z-A",1).''; + } + if ($sortorder == 'ASC' ) { + $out.= ''.img_down("A-Z",1).''; + $out.= ''.img_up("Z-A",0).''; + } + } + } + } + $out.=''; - return $out; + return $out; } /** @@ -2319,7 +2319,7 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m */ function print_titre($title) { - print '
'.$title.'
'; + print '
'.$title.'
'; } /** @@ -2334,7 +2334,7 @@ function print_titre($title) */ function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='') { - print load_fiche_titre($titre, $mesg, $picto, $pictoisfullpath, $id); + print load_fiche_titre($titre, $mesg, $picto, $pictoisfullpath, $id); } /** @@ -2349,26 +2349,26 @@ function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpat */ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='') { - global $conf; + global $conf; - $return=''; + $return=''; - if ($picto == 'setup') $picto='title.png'; - if (!empty($conf->browser->ie) && $picto=='title.png') $picto='title.gif'; + if ($picto == 'setup') $picto='title.png'; + if (!empty($conf->browser->ie) && $picto=='title.png') $picto='title.gif'; - $return.= "\n"; - $return.= ''; - if ($picto) $return.= ''; - $return.= ''; - if (dol_strlen($mesg)) - { - $return.= ''; - } - $return.= '
'.img_picto('',$picto, 'id="pictotitle"', $pictoisfullpath).''; - $return.= '
'.$titre.'
'; - $return.= '
'.$mesg.'
'."\n"; + $return.= "\n"; + $return.= ''; + if ($picto) $return.= ''; + $return.= ''; + if (dol_strlen($mesg)) + { + $return.= ''; + } + $return.= '
'.img_picto('',$picto, 'id="pictotitle"', $pictoisfullpath).''; + $return.= '
'.$titre.'
'; + $return.= '
'.$mesg.'
'."\n"; - return $return; + return $return; } /** @@ -2389,97 +2389,97 @@ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath */ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title.png', $pictoisfullpath=0) { - global $conf,$langs; + global $conf,$langs; - if ($picto == 'setup') $picto='title.png'; - if (!empty($conf->browser->ie) && $picto=='title.png') $picto='title.gif'; + if ($picto == 'setup') $picto='title.png'; + if (!empty($conf->browser->ie) && $picto=='title.png') $picto='title.gif'; - if ($num > $conf->liste_limit or $num == -1) - { - $nextpage = 1; - } - else - { - $nextpage = 0; - } + if ($num > $conf->liste_limit or $num == -1) + { + $nextpage = 1; + } + else + { + $nextpage = 0; + } - print "\n"; - print "\n"; - print ''; + print "\n"; + print "\n"; + print '
'; - $pagelist = ''; + $pagelist = ''; - // Left - if ($page > 0 || $num > $conf->liste_limit) - { - if ($totalnboflines) - { - if ($picto && $titre) print ''; - print ''; + // Left + if ($page > 0 || $num > $conf->liste_limit) + { + if ($totalnboflines) + { + if ($picto && $titre) print ''; + print ''; - $maxnbofpage=10; + $maxnbofpage=10; - $nbpages=ceil($totalnboflines/$conf->liste_limit); - $cpt=($page-$maxnbofpage); - if ($cpt < 0) { $cpt=0; } - $pagelist.=$langs->trans('Page'); - if ($cpt>=1) - { - $pagelist.=' 1'; - if ($cpt >= 2) $pagelist.=' ...'; - } - do - { - if($cpt==$page) - { - $pagelist.= ' '.($page+1).''; - } - else - { - $pagelist.= ' '.($cpt+1).''; - } - $cpt++; - } - while ($cpt < $nbpages && $cpt<=$page+$maxnbofpage); - if ($cpt<$nbpages) - { - if ($cpt<$nbpages-1) $pagelist.= ' ...'; - $pagelist.= ' '.$nbpages.''; - } - } - else - { - if (empty($conf->browser->phone) && $picto && $titre) print ''; - print ''; - } - } - else - { - if (empty($conf->browser->phone) && $picto && $titre) print ''; - print ''; - } + $nbpages=ceil($totalnboflines/$conf->liste_limit); + $cpt=($page-$maxnbofpage); + if ($cpt < 0) { $cpt=0; } + $pagelist.=$langs->trans('Page'); + if ($cpt>=1) + { + $pagelist.=' 1'; + if ($cpt >= 2) $pagelist.=' ...'; + } + do + { + if($cpt==$page) + { + $pagelist.= ' '.($page+1).''; + } + else + { + $pagelist.= ' '.($cpt+1).''; + } + $cpt++; + } + while ($cpt < $nbpages && $cpt<=$page+$maxnbofpage); + if ($cpt<$nbpages) + { + if ($cpt<$nbpages-1) $pagelist.= ' ...'; + $pagelist.= ' '.$nbpages.''; + } + } + else + { + if (empty($conf->browser->phone) && $picto && $titre) print ''; + print ''; + } + } + else + { + if (empty($conf->browser->phone) && $picto && $titre) print ''; + print ''; + } - // Center - if ($center) - { - print ''; - } + // Center + if ($center) + { + print ''; + } - // Right - print ''; + // Right + print ''; - print '
'.img_picto('',$picto, '', $pictoisfullpath).''; - print '
'.$titre.'
'; - print '
'.img_picto('',$picto, '', $pictoisfullpath).''; + print '
'.$titre.'
'; + print '
'.img_picto('',$picto, '', $pictoisfullpath).''; - print '
'.$titre.'
'; - $pagelist.= $langs->trans('Page').' '.($page+1); - print '
'.img_picto('',$picto, '', $pictoisfullpath).'
'.$titre.'
'.img_picto('',$picto, '', $pictoisfullpath).''; + print '
'.$titre.'
'; + $pagelist.= $langs->trans('Page').' '.($page+1); + print '
'.img_picto('',$picto, '', $pictoisfullpath).'
'.$titre.'
'.$center.''.$center.''; - if ($sortfield) $options .= "&sortfield=".$sortfield; - if ($sortorder) $options .= "&sortorder=".$sortorder; - // Affichage des fleches de navigation - print_fleche_navigation($page,$file,$options,$nextpage,$pagelist); - print ''; + if ($sortfield) $options .= "&sortfield=".$sortfield; + if ($sortorder) $options .= "&sortorder=".$sortorder; + // Affichage des fleches de navigation + print_fleche_navigation($page,$file,$options,$nextpage,$pagelist); + print '
'."\n"; - print "\n\n"; + print ''."\n"; + print "\n\n"; } /** @@ -2494,16 +2494,16 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so */ function print_fleche_navigation($page,$file,$options='',$nextpage=0,$betweenarrows='') { - global $conf, $langs; - if ($page > 0) - { - print ''.img_previous($langs->trans("Previous")).''; - } - if ($betweenarrows) print ($page > 0?' ':'').$betweenarrows.($nextpage>0?' ':''); - if ($nextpage > 0) - { - print ''.img_next($langs->trans("Next")).''; - } + global $conf, $langs; + if ($page > 0) + { + print ''.img_previous($langs->trans("Previous")).''; + } + if ($betweenarrows) print ($page > 0?' ':'').$betweenarrows.($nextpage>0?' ':''); + if ($nextpage > 0) + { + print ''.img_next($langs->trans("Next")).''; + } } @@ -2519,21 +2519,21 @@ function print_fleche_navigation($page,$file,$options='',$nextpage=0,$betweenarr */ function vatrate($rate,$addpercent=false,$info_bits=0,$usestarfornpr=0) { - // Test for compatibility - if (preg_match('/%/',$rate)) - { - $rate=str_replace('%','',$rate); - $addpercent=true; - } - if (preg_match('/\*/',$rate) || preg_match('/'.constant('MAIN_LABEL_MENTION_NPR').'/i',$rate)) - { - $rate=str_replace('*','',$rate); - $info_bits |= 1; - } + // Test for compatibility + if (preg_match('/%/',$rate)) + { + $rate=str_replace('%','',$rate); + $addpercent=true; + } + if (preg_match('/\*/',$rate) || preg_match('/'.constant('MAIN_LABEL_MENTION_NPR').'/i',$rate)) + { + $rate=str_replace('*','',$rate); + $info_bits |= 1; + } - $ret=price($rate,0,'',0,0).($addpercent?'%':''); - if ($info_bits & 1) $ret.=' '.($usestarfornpr?'*':constant('MAIN_LABEL_MENTION_NPR')); - return $ret; + $ret=price($rate,0,'',0,0).($addpercent?'%':''); + if ($info_bits & 1) $ret.=' '.($usestarfornpr?'*':constant('MAIN_LABEL_MENTION_NPR')); + return $ret; } @@ -2553,62 +2553,62 @@ function vatrate($rate,$addpercent=false,$info_bits=0,$usestarfornpr=0) */ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1) { - global $langs,$conf; + global $langs,$conf; - // Clean parameters - if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' - if ($rounding < 0) $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); + // Clean parameters + if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' + if ($rounding < 0) $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); - $nbdecimal=$rounding; + $nbdecimal=$rounding; - // Output separators by default (french) - $dec=','; $thousand=' '; + // Output separators by default (french) + $dec=','; $thousand=' '; - // If $outlangs not forced, we use use language - if (! is_object($outlangs)) $outlangs=$langs; + // If $outlangs not forced, we use use language + if (! is_object($outlangs)) $outlangs=$langs; - if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal"); - if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand"); - if ($thousand == 'None') $thousand=''; - //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
"; + if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal"); + if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand"); + if ($thousand == 'None') $thousand=''; + //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
"; - //print "amount=".$amount."-"; - $amount = str_replace(',','.',$amount); // should be useless - //print $amount."-"; - $datas = explode('.',$amount); - $decpart = isset($datas[1])?$datas[1]:''; - $decpart = preg_replace('/0+$/i','',$decpart); // Supprime les 0 de fin de partie decimale - //print "decpart=".$decpart."
"; - $end=''; + //print "amount=".$amount."-"; + $amount = str_replace(',','.',$amount); // should be useless + //print $amount."-"; + $datas = explode('.',$amount); + $decpart = isset($datas[1])?$datas[1]:''; + $decpart = preg_replace('/0+$/i','',$decpart); // Supprime les 0 de fin de partie decimale + //print "decpart=".$decpart."
"; + $end=''; - // We increase nbdecimal if there is more decimal than asked (to not loose information) - if (dol_strlen($decpart) > $nbdecimal) $nbdecimal=dol_strlen($decpart); - // Si on depasse max - if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) - { - $nbdecimal=$conf->global->MAIN_MAX_DECIMALS_SHOWN; - if (preg_match('/\.\.\./i',$conf->global->MAIN_MAX_DECIMALS_SHOWN)) - { - // Si un affichage est tronque, on montre des ... - $end='...'; - } - } + // We increase nbdecimal if there is more decimal than asked (to not loose information) + if (dol_strlen($decpart) > $nbdecimal) $nbdecimal=dol_strlen($decpart); + // Si on depasse max + if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) + { + $nbdecimal=$conf->global->MAIN_MAX_DECIMALS_SHOWN; + if (preg_match('/\.\.\./i',$conf->global->MAIN_MAX_DECIMALS_SHOWN)) + { + // Si un affichage est tronque, on montre des ... + $end='...'; + } + } - // If force rounding - if ($forcerounding >= 0) $nbdecimal = $forcerounding; + // If force rounding + if ($forcerounding >= 0) $nbdecimal = $forcerounding; - // Format number - if ($form) - { - $output=preg_replace('/\s/',' ',number_format($amount, $nbdecimal, $dec, $thousand)); - } - else - { - $output=number_format($amount, $nbdecimal, $dec, $thousand); - } - $output.=$end; + // Format number + if ($form) + { + $output=preg_replace('/\s/',' ',number_format($amount, $nbdecimal, $dec, $thousand)); + } + else + { + $output=number_format($amount, $nbdecimal, $dec, $thousand); + } + $output.=$end; - return $output; + return $output; } /** @@ -2628,75 +2628,75 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou */ function price2num($amount,$rounding='',$alreadysqlnb=0) { - global $langs,$conf; + global $langs,$conf; - // Round PHP function does not allow number like '1,234.56' nor '1.234,56' nor '1 234,56' - // Numbers must be '1234.56' - // Decimal delimiter for PHP and database SQL requests must be '.' - $dec=','; $thousand=' '; - if ($langs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->trans("SeparatorDecimal"); - if ($langs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->trans("SeparatorThousand"); - if ($thousand == 'None') $thousand=''; - //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
"; + // Round PHP function does not allow number like '1,234.56' nor '1.234,56' nor '1 234,56' + // Numbers must be '1234.56' + // Decimal delimiter for PHP and database SQL requests must be '.' + $dec=','; $thousand=' '; + if ($langs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->trans("SeparatorDecimal"); + if ($langs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->trans("SeparatorThousand"); + if ($thousand == 'None') $thousand=''; + //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
"; - // Convert value to universal number format (no thousand separator, '.' as decimal separator) - if ($alreadysqlnb != 1) // If not a PHP number or unknown, we change format - { - //print 'PP'.$amount.' - '.$dec.' - '.$thousand.'
'; + // Convert value to universal number format (no thousand separator, '.' as decimal separator) + if ($alreadysqlnb != 1) // If not a PHP number or unknown, we change format + { + //print 'PP'.$amount.' - '.$dec.' - '.$thousand.'
'; - // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number - // to format defined by LC_NUMERIC after a calculation and we want source format to be like defined by Dolibarr setup. - if (is_numeric($amount)) - { - // We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10 - $temps=sprintf("%0.10F",$amount-intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000 - $temps=preg_replace('/([\.1-9])0+$/','\\1',$temps); // temps=0. or 0.00002 or 9999.1 - $nbofdec=max(0,dol_strlen($temps)-2); // -2 to remove "0." - $amount=number_format($amount,$nbofdec,$dec,$thousand); - } - //print "QQ".$amount.'
'; + // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number + // to format defined by LC_NUMERIC after a calculation and we want source format to be like defined by Dolibarr setup. + if (is_numeric($amount)) + { + // We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10 + $temps=sprintf("%0.10F",$amount-intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000 + $temps=preg_replace('/([\.1-9])0+$/','\\1',$temps); // temps=0. or 0.00002 or 9999.1 + $nbofdec=max(0,dol_strlen($temps)-2); // -2 to remove "0." + $amount=number_format($amount,$nbofdec,$dec,$thousand); + } + //print "QQ".$amount.'
'; - // Now make replace (the main goal of function) - if ($thousand != ',' && $thousand != '.') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users - $amount=str_replace(' ','',$amount); // To avoid spaces - $amount=str_replace($thousand,'',$amount); // Replace of thousand before replace of dec to avoid pb if thousand is . - $amount=str_replace($dec,'.',$amount); - } + // Now make replace (the main goal of function) + if ($thousand != ',' && $thousand != '.') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users + $amount=str_replace(' ','',$amount); // To avoid spaces + $amount=str_replace($thousand,'',$amount); // Replace of thousand before replace of dec to avoid pb if thousand is . + $amount=str_replace($dec,'.',$amount); + } - // Now, make a rounding if required - if ($rounding) - { - $nbofdectoround=''; - if ($rounding == 'MU') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT; - elseif ($rounding == 'MT') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT; - elseif ($rounding == 'MS') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_SHOWN; - elseif ($rounding == '2') $nbofdectoround=2; // For admin info page - //print "RR".$amount.' - '.$nbofdectoround.'
'; - if (dol_strlen($nbofdectoround)) $amount = round($amount,$nbofdectoround); // $nbofdectoround can be 0. - else return 'ErrorBadParameterProvidedToFunction'; - //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'
'; + // Now, make a rounding if required + if ($rounding) + { + $nbofdectoround=''; + if ($rounding == 'MU') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT; + elseif ($rounding == 'MT') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT; + elseif ($rounding == 'MS') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_SHOWN; + elseif ($rounding == '2') $nbofdectoround=2; // For admin info page + //print "RR".$amount.' - '.$nbofdectoround.'
'; + if (dol_strlen($nbofdectoround)) $amount = round($amount,$nbofdectoround); // $nbofdectoround can be 0. + else return 'ErrorBadParameterProvidedToFunction'; + //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'
'; - // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number - // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup. - if (is_numeric($amount)) - { - // We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10 - $temps=sprintf("%0.10F",$amount-intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000 - $temps=preg_replace('/([\.1-9])0+$/','\\1',$temps); // temps=0. or 0.00002 or 9999.1 - $nbofdec=max(0,dol_strlen($temps)-2); // -2 to remove "0." - $amount=number_format($amount,min($nbofdec,$nbofdectoround),$dec,$thousand); // Convert amount to format with dolibarr dec and thousand - } - //print "TT".$amount.'
'; + // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number + // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup. + if (is_numeric($amount)) + { + // We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10 + $temps=sprintf("%0.10F",$amount-intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000 + $temps=preg_replace('/([\.1-9])0+$/','\\1',$temps); // temps=0. or 0.00002 or 9999.1 + $nbofdec=max(0,dol_strlen($temps)-2); // -2 to remove "0." + $amount=number_format($amount,min($nbofdec,$nbofdectoround),$dec,$thousand); // Convert amount to format with dolibarr dec and thousand + } + //print "TT".$amount.'
'; - // Always make replace because each math function (like round) replace - // with local values and we want a number that has a SQL string format x.y - if ($thousand != ',' && $thousand != '.') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users - $amount=str_replace(' ','',$amount); // To avoid spaces - $amount=str_replace($thousand,'',$amount); // Replace of thousand before replace of dec to avoid pb if thousand is . - $amount=str_replace($dec,'.',$amount); - } + // Always make replace because each math function (like round) replace + // with local values and we want a number that has a SQL string format x.y + if ($thousand != ',' && $thousand != '.') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users + $amount=str_replace(' ','',$amount); // To avoid spaces + $amount=str_replace($thousand,'',$amount); // Replace of thousand before replace of dec to avoid pb if thousand is . + $amount=str_replace($dec,'.',$amount); + } - return $amount; + return $amount; } /** @@ -2709,35 +2709,35 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) */ function get_localtax($tva, $local, $societe_acheteuse="") { - global $db, $conf, $mysoc; + global $db, $conf, $mysoc; - if ($local == 1 && ! $mysoc->localtax1_assuj) return 0; - if ($local == 2 && ! $mysoc->localtax2_assuj) return 0; + if ($local == 1 && ! $mysoc->localtax1_assuj) return 0; + if ($local == 2 && ! $mysoc->localtax2_assuj) return 0; - $code_pays=$mysoc->pays_code; + $code_pays=$mysoc->pays_code; - if (is_object($societe_acheteuse)) - { - if ($code_pays!=$societe_acheteuse->pays_code) return 0; - if ($local==1 && !$societe_acheteuse->localtax1_assuj) return 0; - elseif ($local==2 && !$societe_acheteuse->localtax2_assuj) return 0; - } + if (is_object($societe_acheteuse)) + { + if ($code_pays!=$societe_acheteuse->pays_code) return 0; + if ($local==1 && !$societe_acheteuse->localtax1_assuj) return 0; + elseif ($local==2 && !$societe_acheteuse->localtax2_assuj) return 0; + } - // Search local taxes - $sql = "SELECT t.localtax1, t.localtax2"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'"; - $sql .= " AND t.taux = ".$tva." AND t.active = 1"; + // Search local taxes + $sql = "SELECT t.localtax1, t.localtax2"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; + $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'"; + $sql .= " AND t.taux = ".$tva." AND t.active = 1"; - $resql=$db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if ($local==1) return $obj->localtax1; - elseif ($local==2) return $obj->localtax2; - } + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($local==1) return $obj->localtax1; + elseif ($local==2) return $obj->localtax2; + } - return 0; + return 0; } /** @@ -2752,61 +2752,61 @@ function get_localtax($tva, $local, $societe_acheteuse="") */ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice=0) { - global $db,$mysoc; + global $db,$mysoc; - $ret=0; - $found=0; + $ret=0; + $found=0; - if ($idprod > 0) - { - // Load product - $product=new Product($db); - $result=$product->fetch($idprod); + if ($idprod > 0) + { + // Load product + $product=new Product($db); + $result=$product->fetch($idprod); - if ($mysoc->pays_code == $thirdparty_seller->country_code) // If selling country is ours - { - if ($idprodfournprice > 0) // We want vat for product for a supplier order or invoice - { - $product->get_buyprice($idprodfournprice,0,0,0); - $ret=$product->vatrate_supplier; - } - else - { - $ret=$product->tva_tx; // Default vat of product we defined - } - $found=1; - } - else - { - // TODO Read default product vat according to countrycode and product + if ($mysoc->pays_code == $thirdparty_seller->country_code) // If selling country is ours + { + if ($idprodfournprice > 0) // We want vat for product for a supplier order or invoice + { + $product->get_buyprice($idprodfournprice,0,0,0); + $ret=$product->vatrate_supplier; + } + else + { + $ret=$product->tva_tx; // Default vat of product we defined + } + $found=1; + } + else + { + // TODO Read default product vat according to countrycode and product - } - } + } + } - if (! $found) - { - // If vat of product for the country not found or not defined, we return higher vat of country. - $sql = "SELECT taux as vat_rate"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql.= " WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$thirdparty_seller->country_code."'"; - $sql.= " ORDER BY t.taux DESC, t.recuperableonly ASC"; - $sql.= $db->plimit(1); + if (! $found) + { + // If vat of product for the country not found or not defined, we return higher vat of country. + $sql = "SELECT taux as vat_rate"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; + $sql.= " WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$thirdparty_seller->country_code."'"; + $sql.= " ORDER BY t.taux DESC, t.recuperableonly ASC"; + $sql.= $db->plimit(1); - $resql=$db->query($sql); - if ($resql) - { - $obj=$db->fetch_object($resql); - if ($obj) - { - $ret=$obj->vat_rate; - } - } - else dol_print_error($db); - } + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if ($obj) + { + $ret=$obj->vat_rate; + } + } + else dol_print_error($db); + } - dol_syslog("get_product_vat_for_country: ret=".$ret); - return $ret; + dol_syslog("get_product_vat_for_country: ret=".$ret); + return $ret; } /** @@ -2820,15 +2820,15 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr */ function get_product_localtax_for_country($idprod, $local, $countrycode) { - global $db; + global $db; - $product=new Product($db); - $product->fetch($idprod); + $product=new Product($db); + $product->fetch($idprod); - if ($local==1) return $product->localtax1_tx; - elseif ($local==2) return $product->localtax2_tx; + if ($local==1) return $product->localtax1_tx; + elseif ($local==2) return $product->localtax2_tx; - return -1; + return -1; } /** @@ -2848,72 +2848,72 @@ function get_product_localtax_for_country($idprod, $local, $countrycode) */ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0, $idprodfournprice=0) { - global $conf; + global $conf; - if (!is_object($societe_vendeuse)) return -1; - if (!is_object($societe_acheteuse)) return -1; + if (!is_object($societe_vendeuse)) return -1; + if (!is_object($societe_acheteuse)) return -1; - dol_syslog("get_default_tva: seller use vat=".$societe_vendeuse->tva_assuj.", seller country=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", buyer country=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)?$conf->global->SERVICES_ARE_ECOMMERCE_200238EC:'')); + dol_syslog("get_default_tva: seller use vat=".$societe_vendeuse->tva_assuj.", seller country=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", buyer country=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)?$conf->global->SERVICES_ARE_ECOMMERCE_200238EC:'')); - // Si vendeur non assujeti a TVA (tva_assuj vaut 0/1 ou franchise/reel) - if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) - { - //print 'VATRULE 1'; - return 0; - } - if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') - { - //print 'VATRULE 2'; - return 0; - } + // Si vendeur non assujeti a TVA (tva_assuj vaut 0/1 ou franchise/reel) + if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) + { + //print 'VATRULE 1'; + return 0; + } + if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') + { + //print 'VATRULE 2'; + return 0; + } - //if (is_object($societe_acheteuse) && ($societe_vendeuse->country_id == $societe_acheteuse->country_id) && ($societe_acheteuse->tva_assuj == 1 || $societe_acheteuse->tva_assuj == 'reel')) - // Le test ci-dessus ne devrait pas etre necessaire. Me signaler l'exemple du cas juridique concerne si le test suivant n'est pas suffisant. + //if (is_object($societe_acheteuse) && ($societe_vendeuse->country_id == $societe_acheteuse->country_id) && ($societe_acheteuse->tva_assuj == 1 || $societe_acheteuse->tva_assuj == 'reel')) + // Le test ci-dessus ne devrait pas etre necessaire. Me signaler l'exemple du cas juridique concerne si le test suivant n'est pas suffisant. - // Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. - if (($societe_vendeuse->country_code == $societe_acheteuse->country_code) - || (in_array($societe_vendeuse->country_code,array('FR,MC')) && in_array($societe_acheteuse->country_code,array('FR','MC')))) // Warning ->country_code not always defined - { - //print 'VATRULE 3'; - return get_product_vat_for_country($idprod,$societe_vendeuse,$idprodfournprice); - } + // Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. + if (($societe_vendeuse->country_code == $societe_acheteuse->country_code) + || (in_array($societe_vendeuse->country_code,array('FR,MC')) && in_array($societe_acheteuse->country_code,array('FR','MC')))) // Warning ->country_code not always defined + { + //print 'VATRULE 3'; + return get_product_vat_for_country($idprod,$societe_vendeuse,$idprodfournprice); + } - // Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. - // Non gere + // Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. + // Non gere - // Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise) alors TVA par defaut=0. Fin de regle - // Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle - if (($societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC())) - { - $isacompany=$societe_acheteuse->isACompany(); - if ($isacompany) - { - //print 'VATRULE 4'; - return 0; - } - else - { - //print 'VATRULE 5'; - return get_product_vat_for_country($idprod,$societe_vendeuse,$idprodfournprice); - } - } + // Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise) alors TVA par defaut=0. Fin de regle + // Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle + if (($societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC())) + { + $isacompany=$societe_acheteuse->isACompany(); + if ($isacompany) + { + //print 'VATRULE 4'; + return 0; + } + else + { + //print 'VATRULE 5'; + return get_product_vat_for_country($idprod,$societe_vendeuse,$idprodfournprice); + } + } - // If services are eServices according to EU Council Directive 2002/38/EC (ec.europa.eu/taxation_customs/taxation/v.../article_1610_en.htm) - // we use the buyer VAT. - if (! empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) - { - //print "eee".$societe_acheteuse->isACompany();exit; - if (! $societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && ! $societe_acheteuse->isACompany()) - { - //print 'VATRULE 6'; - return get_product_vat_for_country($idprod,$societe_acheteuse,$idprodfournprice); - } - } + // If services are eServices according to EU Council Directive 2002/38/EC (ec.europa.eu/taxation_customs/taxation/v.../article_1610_en.htm) + // we use the buyer VAT. + if (! empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) + { + //print "eee".$societe_acheteuse->isACompany();exit; + if (! $societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && ! $societe_acheteuse->isACompany()) + { + //print 'VATRULE 6'; + return get_product_vat_for_country($idprod,$societe_acheteuse,$idprodfournprice); + } + } - // Sinon la TVA proposee par defaut=0. Fin de regle. - // Rem: Cela signifie qu'au moins un des 2 est hors Communaute europeenne et que le pays differe - //print 'VATRULE 7'; - return 0; + // Sinon la TVA proposee par defaut=0. Fin de regle. + // Rem: Cela signifie qu'au moins un des 2 est hors Communaute europeenne et que le pays differe + //print 'VATRULE 7'; + return 0; } @@ -2927,7 +2927,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0, $idpr */ function get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod) { - return 0; + return 0; } /** @@ -2941,28 +2941,28 @@ function get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod) */ function get_default_localtax($societe_vendeuse, $societe_acheteuse, $local, $idprod=0) { - if (!is_object($societe_vendeuse)) return -1; - if (!is_object($societe_acheteuse)) return -1; + if (!is_object($societe_vendeuse)) return -1; + if (!is_object($societe_acheteuse)) return -1; - if ($societe_vendeuse->country_id=='ES' || $societe_vendeuse->country_code=='ES') - { - if ($local==1) //RE - { - // Si achatteur non assujeti a RE, localtax1 par default=0 - if (is_numeric($societe_acheteuse->localtax1_assuj) && ! $societe_acheteuse->localtax1_assuj) return 0; - if (! is_numeric($societe_acheteuse->localtax1_assuj) && $societe_acheteuse->localtax1_assuj=='localtax1off') return 0; - } - elseif ($local==2) //IRPF - { - // Si vendeur non assujeti a IRPF, localtax2 par default=0 - if (is_numeric($societe_vendeuse->localtax2_assuj) && ! $societe_vendeuse->localtax2_assuj) return 0; - if (! is_numeric($societe_vendeuse->localtax2_assuj) && $societe_vendeuse->localtax2_assuj=='localtax2off') return 0; - } else return -1; + if ($societe_vendeuse->country_id=='ES' || $societe_vendeuse->country_code=='ES') + { + if ($local==1) //RE + { + // Si achatteur non assujeti a RE, localtax1 par default=0 + if (is_numeric($societe_acheteuse->localtax1_assuj) && ! $societe_acheteuse->localtax1_assuj) return 0; + if (! is_numeric($societe_acheteuse->localtax1_assuj) && $societe_acheteuse->localtax1_assuj=='localtax1off') return 0; + } + elseif ($local==2) //IRPF + { + // Si vendeur non assujeti a IRPF, localtax2 par default=0 + if (is_numeric($societe_vendeuse->localtax2_assuj) && ! $societe_vendeuse->localtax2_assuj) return 0; + if (! is_numeric($societe_vendeuse->localtax2_assuj) && $societe_vendeuse->localtax2_assuj=='localtax2off') return 0; + } else return -1; - if ($idprod) return get_product_localtax_for_country($idprod, $local, $societe_vendeuse->country_code); - else return -1; - } - return 0; + if ($idprod) return get_product_localtax_for_country($idprod, $local, $societe_vendeuse->country_code); + else return -1; + } + return 0; } /** @@ -2975,21 +2975,21 @@ function get_default_localtax($societe_vendeuse, $societe_acheteuse, $local, $id */ function yn($yesno, $case=1, $color=0) { - global $langs; - $result='unknown'; - if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') // A mettre avant test sur no a cause du == 0 - { - $result=($case?$langs->trans("Yes"):$langs->trans("yes")); - $classname='ok'; - } - elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') - { - $result=($case?$langs->trans("No"):$langs->trans("no")); - if ($color == 2) $classname='ok'; - else $classname='error'; - } - if ($color) return ''.$result.''; - return $result; + global $langs; + $result='unknown'; + if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') // A mettre avant test sur no a cause du == 0 + { + $result=($case?$langs->trans("Yes"):$langs->trans("yes")); + $classname='ok'; + } + elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') + { + $result=($case?$langs->trans("No"):$langs->trans("no")); + if ($color == 2) $classname='ok'; + else $classname='error'; + } + if ($color) return ''.$result.''; + return $result; } @@ -3006,15 +3006,15 @@ function yn($yesno, $case=1, $color=0) */ function get_exdir($num,$level=3,$alpha=0,$withoutslash=0) { - $path = ''; - if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num); - else $num = preg_replace('/^.*\-/i','',$num); - $num = substr("000".$num, -$level); - if ($level == 1) $path = substr($num,0,1); - if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1); - if ($level == 3) $path = substr($num,2,1).'/'.substr($num,1,1).'/'.substr($num,0,1); - if (empty($withoutslash)) $path.='/'; - return $path; + $path = ''; + if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num); + else $num = preg_replace('/^.*\-/i','',$num); + $num = substr("000".$num, -$level); + if ($level == 1) $path = substr($num,0,1); + if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1); + if ($level == 3) $path = substr($num,2,1).'/'.substr($num,1,1).'/'.substr($num,0,1); + if (empty($withoutslash)) $path.='/'; + return $path; } /** @@ -3025,58 +3025,58 @@ function get_exdir($num,$level=3,$alpha=0,$withoutslash=0) */ function dol_mkdir($dir) { - global $conf; + global $conf; - dol_syslog("functions.lib::dol_mkdir: dir=".$dir,LOG_INFO); + dol_syslog("functions.lib::dol_mkdir: dir=".$dir,LOG_INFO); - $dir_osencoded=dol_osencode($dir); - if (@is_dir($dir_osencoded)) return 0; + $dir_osencoded=dol_osencode($dir); + if (@is_dir($dir_osencoded)) return 0; - $nberr=0; - $nbcreated=0; + $nberr=0; + $nbcreated=0; - $ccdir = ''; - $cdir = explode("/",$dir); - $num=count($cdir); - for ($i = 0; $i < $num; $i++) - { - if ($i > 0) $ccdir .= '/'.$cdir[$i]; - else $ccdir = $cdir[$i]; - if (preg_match("/^.:$/",$ccdir,$regs)) continue; // Si chemin Windows incomplet, on poursuit par rep suivant + $ccdir = ''; + $cdir = explode("/",$dir); + $num=count($cdir); + for ($i = 0; $i < $num; $i++) + { + if ($i > 0) $ccdir .= '/'.$cdir[$i]; + else $ccdir = $cdir[$i]; + if (preg_match("/^.:$/",$ccdir,$regs)) continue; // Si chemin Windows incomplet, on poursuit par rep suivant - // Attention, le is_dir() peut echouer bien que le rep existe. - // (ex selon config de open_basedir) - if ($ccdir) - { - $ccdir_osencoded=dol_osencode($ccdir); - if (! @is_dir($ccdir_osencoded)) - { - dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.",LOG_DEBUG); + // Attention, le is_dir() peut echouer bien que le rep existe. + // (ex selon config de open_basedir) + if ($ccdir) + { + $ccdir_osencoded=dol_osencode($ccdir); + if (! @is_dir($ccdir_osencoded)) + { + dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.",LOG_DEBUG); - umask(0); - $dirmaskdec=octdec('0755'); - if (! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK); - $dirmaskdec |= octdec('0111'); // Set x bit required for directories - if (! @mkdir($ccdir_osencoded, $dirmaskdec)) - { - // Si le is_dir a renvoye une fausse info, alors on passe ici. - dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.",LOG_WARNING); - $nberr++; - } - else - { - dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' created",LOG_DEBUG); - $nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignore - $nbcreated++; - } - } - else - { - $nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignores - } - } - } - return ($nberr ? -$nberr : $nbcreated); + umask(0); + $dirmaskdec=octdec('0755'); + if (! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK); + $dirmaskdec |= octdec('0111'); // Set x bit required for directories + if (! @mkdir($ccdir_osencoded, $dirmaskdec)) + { + // Si le is_dir a renvoye une fausse info, alors on passe ici. + dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.",LOG_WARNING); + $nberr++; + } + else + { + dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' created",LOG_DEBUG); + $nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignore + $nbcreated++; + } + } + else + { + $nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignores + } + } + } + return ($nberr ? -$nberr : $nbcreated); } @@ -3087,7 +3087,7 @@ function dol_mkdir($dir) */ function picto_required() { - return '*'; + return '*'; } @@ -3101,20 +3101,20 @@ function picto_required() */ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') { - $pattern = "/<[^>]+>/"; - $temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto); - $temp = preg_replace($pattern,"",$temp); + $pattern = "/<[^>]+>/"; + $temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto); + $temp = preg_replace($pattern,"",$temp); - // Supprime aussi les retours - if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp); + // Supprime aussi les retours + if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp); - // et les espaces doubles - while(strpos($temp," ")) - { - $temp = str_replace(" "," ",$temp); - } - $CleanString = trim($temp); - return $CleanString; + // et les espaces doubles + while(strpos($temp," ")) + { + $temp = str_replace(" "," ",$temp); + } + $CleanString = trim($temp); + return $CleanString; } @@ -3128,17 +3128,17 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') */ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false) { - if (! $nl2brmode) - { - // We use @ to avoid warning on PHP4 that does not support entity encoding from UTF8; - if (version_compare(PHP_VERSION, '5.3.0') < 0) return @nl2br($stringtoencode); - else return @nl2br($stringtoencode,$forxml); - } - else - { - $ret=preg_replace('/(\r\n|\r|\n)/i',($forxml?'
':'
'),$stringtoencode); - return $ret; - } + if (! $nl2brmode) + { + // We use @ to avoid warning on PHP4 that does not support entity encoding from UTF8; + if (version_compare(PHP_VERSION, '5.3.0') < 0) return @nl2br($stringtoencode); + else return @nl2br($stringtoencode,$forxml); + } + else + { + $ret=preg_replace('/(\r\n|\r|\n)/i',($forxml?'
':'
'),$stringtoencode); + return $ret; + } } /** @@ -3159,23 +3159,23 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false) */ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8') { - if (dol_textishtml($stringtoencode)) - { - $newstring=$stringtoencode; - $newstring=preg_replace('//i','
',$newstring); // Replace "
" by "
". It's same and avoid pb with FPDF. - $newstring=preg_replace('/
$/i','',$newstring); // Remove last
- $newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__')); - $newstring=dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding - $newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"')); - //$newstring=strtr($newstring,array('__li__'=>"
  • \n")); // Restore
  • \n - } - else - { - $newstring=dol_nl2br(dol_htmlentities($stringtoencode,ENT_COMPAT,$pagecodefrom),$nl2brmode); - } - // Other substitutions that htmlentities does not do - //$newstring=str_replace(chr(128),'€',$newstring); // 128 = 0x80. Not in html entity table. // Seems useles with TCPDF. Make bug with UTF8 languages - return $newstring; + if (dol_textishtml($stringtoencode)) + { + $newstring=$stringtoencode; + $newstring=preg_replace('//i','
    ',$newstring); // Replace "
    " by "
    ". It's same and avoid pb with FPDF. + $newstring=preg_replace('/
    $/i','',$newstring); // Remove last
    + $newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__')); + $newstring=dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding + $newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"')); + //$newstring=strtr($newstring,array('__li__'=>"
  • \n")); // Restore
  • \n + } + else + { + $newstring=dol_nl2br(dol_htmlentities($stringtoencode,ENT_COMPAT,$pagecodefrom),$nl2brmode); + } + // Other substitutions that htmlentities does not do + //$newstring=str_replace(chr(128),'€',$newstring); // 128 = 0x80. Not in html entity table. // Seems useles with TCPDF. Make bug with UTF8 languages + return $newstring; } /** @@ -3187,12 +3187,12 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8') */ function dol_htmlentitiesbr_decode($stringtodecode,$pagecodeto='UTF-8') { - $ret=dol_html_entity_decode($stringtodecode,ENT_COMPAT,$pagecodeto); - $ret=preg_replace('/'."\r\n".'/i',"
    ",$ret); - $ret=preg_replace('/'."\r\n".'/i',"\r\n",$ret); - $ret=preg_replace('/'."\n".'/i',"\n",$ret); - $ret=preg_replace('//i',"\n",$ret); - return $ret; + $ret=dol_html_entity_decode($stringtodecode,ENT_COMPAT,$pagecodeto); + $ret=preg_replace('/'."\r\n".'/i',"
    ",$ret); + $ret=preg_replace('/'."\r\n".'/i',"\r\n",$ret); + $ret=preg_replace('/'."\n".'/i',"\n",$ret); + $ret=preg_replace('//i',"\n",$ret); + return $ret; } /** @@ -3203,8 +3203,8 @@ function dol_htmlentitiesbr_decode($stringtodecode,$pagecodeto='UTF-8') */ function dol_htmlcleanlastbr($stringtodecode) { - $ret=preg_replace('/(
    ||'."\n".'|'."\r".')+$/i',"",$stringtodecode); - return $ret; + $ret=preg_replace('/(
    ||'."\n".'|'."\r".')+$/i',"",$stringtodecode); + return $ret; } /** @@ -3217,9 +3217,9 @@ function dol_htmlcleanlastbr($stringtodecode) */ function dol_html_entity_decode($a,$b,$c='UTF-8') { - // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; - $ret=@html_entity_decode($a,$b,$c); - return $ret; + // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; + $ret=@html_entity_decode($a,$b,$c); + return $ret; } /** @@ -3232,9 +3232,9 @@ function dol_html_entity_decode($a,$b,$c='UTF-8') */ function dol_htmlentities($a,$b,$c='UTF-8') { - // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; - $ret=@htmlentities($a,$b,$c); - return $ret; + // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; + $ret=@htmlentities($a,$b,$c); + return $ret; } @@ -3248,16 +3248,16 @@ function dol_htmlentities($a,$b,$c='UTF-8') */ function dol_string_is_good_iso($s) { - $len=dol_strlen($s); - $ok=1; - for($scursor=0;$scursor<$len;$scursor++) - { - $ordchar=ord($s{$scursor}); - //print $scursor.'-'.$ordchar.'
    '; - if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; } - if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; } - } - return $ok; + $len=dol_strlen($s); + $ok=1; + for($scursor=0;$scursor<$len;$scursor++) + { + $ordchar=ord($s{$scursor}); + //print $scursor.'-'.$ordchar.'
    '; + if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; } + if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; } + } + return $ok; } @@ -3270,11 +3270,11 @@ function dol_string_is_good_iso($s) */ function dol_nboflines($s,$maxchar=0) { - if ($s == '') return 0; - $arraystring=explode("\n",$s); - $nb=count($arraystring); + if ($s == '') return 0; + $arraystring=explode("\n",$s); + $nb=count($arraystring); - return $nb; + return $nb; } @@ -3288,33 +3288,33 @@ function dol_nboflines($s,$maxchar=0) */ function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8') { - $repTable = array("\t" => " ", "\n" => "
    ", "\r" => " ", "\0" => " ", "\x0B" => " "); - if (dol_textishtml($text)) $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); + $repTable = array("\t" => " ", "\n" => "
    ", "\r" => " ", "\0" => " ", "\x0B" => " "); + if (dol_textishtml($text)) $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); - $text = strtr($text, $repTable); - if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support - else $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. - $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $text = strtr($text, $repTable); + if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support + else $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. + $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - $nblines = floor((count($a)+1)/2); - // count possible auto line breaks - if($maxlinesize) - { - foreach ($a as $line) - { - if (dol_strlen($line)>$maxlinesize) - { - //$line_dec = html_entity_decode(strip_tags($line)); - $line_dec = html_entity_decode($line); - if(dol_strlen($line_dec)>$maxlinesize) - { - $line_dec=wordwrap($line_dec,$maxlinesize,'\n',true); - $nblines+=substr_count($line_dec,'\n'); - } - } - } - } - return $nblines; + $nblines = floor((count($a)+1)/2); + // count possible auto line breaks + if($maxlinesize) + { + foreach ($a as $line) + { + if (dol_strlen($line)>$maxlinesize) + { + //$line_dec = html_entity_decode(strip_tags($line)); + $line_dec = html_entity_decode($line); + if(dol_strlen($line_dec)>$maxlinesize) + { + $line_dec=wordwrap($line_dec,$maxlinesize,'\n',true); + $nblines+=substr_count($line_dec,'\n'); + } + } + } + } + return $nblines; } /** @@ -3324,8 +3324,8 @@ function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8') */ function dol_microtime_float() { - list($usec, $sec) = explode(" ", microtime()); - return ((float) $usec + (float) $sec); + list($usec, $sec) = explode(" ", microtime()); + return ((float) $usec + (float) $sec); } /** @@ -3337,31 +3337,31 @@ function dol_microtime_float() */ function dol_textishtml($msg,$option=0) { - if ($option == 1) - { - if (preg_match('//i',$msg)) return true; - elseif (preg_match('//i',$msg)) return true; - elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) - elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) - return false; - } + if ($option == 1) + { + if (preg_match('//i',$msg)) return true; + elseif (preg_match('//i',$msg)) return true; + elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) + elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) + return false; + } } /** @@ -3377,14 +3377,14 @@ function dol_textishtml($msg,$option=0) */ function make_substitutions($chaine,$substitutionarray) { - if (! is_array($substitutionarray)) return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; + if (! is_array($substitutionarray)) return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; - // Make substitition - foreach ($substitutionarray as $key => $value) - { - $chaine=str_replace("$key","$value",$chaine); // We must keep the " to work when value is 123.5 for example - } - return $chaine; + // Make substitition + foreach ($substitutionarray as $key => $value) + { + $chaine=str_replace("$key","$value",$chaine); // We must keep the " to work when value is 123.5 for example + } + return $chaine; } /** @@ -3398,34 +3398,34 @@ function make_substitutions($chaine,$substitutionarray) */ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='') { - global $conf,$user; + global $conf,$user; - require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); + require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); - // Check if there is external substitution to do asked by plugins - $dirsubstitutions=array_merge(array(),(array) $conf->modules_parts['substitutions']); + // Check if there is external substitution to do asked by plugins + $dirsubstitutions=array_merge(array(),(array) $conf->modules_parts['substitutions']); - foreach($dirsubstitutions as $reldir) - { - $dir=dol_buildpath($reldir,0); + foreach($dirsubstitutions as $reldir) + { + $dir=dol_buildpath($reldir,0); - // Check if directory exists - if (! dol_is_dir($dir)) continue; + // Check if directory exists + if (! dol_is_dir($dir)) continue; - $substitfiles=dol_dir_list($dir,'files',0,'functions_'); - foreach($substitfiles as $substitfile) - { - if (preg_match('/functions_(.*)\.lib\.php/i',$substitfile['name'],$reg)) - { - $module=$reg[1]; + $substitfiles=dol_dir_list($dir,'files',0,'functions_'); + foreach($substitfiles as $substitfile) + { + if (preg_match('/functions_(.*)\.lib\.php/i',$substitfile['name'],$reg)) + { + $module=$reg[1]; - dol_syslog("Library functions_".$substitfile['name']." found into ".$dir); - require_once($dir.$substitfile['name']); - $function_name=$module."_completesubstitutionarray"; - $function_name($substitutionarray,$outputlangs,$object); - } - } - } + dol_syslog("Library functions_".$substitfile['name']." found into ".$dir); + require_once($dir.$substitfile['name']); + $function_name=$module."_completesubstitutionarray"; + $function_name($substitutionarray,$outputlangs,$object); + } + } + } } /** @@ -3439,7 +3439,7 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object=' */ function print_date_range($date_start,$date_end,$format = '',$outputlangs='') { - print get_date_range($date_start,$date_end,$format,$outputlangs); + print get_date_range($date_start,$date_end,$format,$outputlangs); } /** @@ -3453,26 +3453,26 @@ function print_date_range($date_start,$date_end,$format = '',$outputlangs='') */ function get_date_range($date_start,$date_end,$format = '',$outputlangs='') { - global $langs; + global $langs; - $out=''; + $out=''; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (! is_object($outputlangs)) $outputlangs=$langs; - if ($date_start && $date_end) - { - $out.= ' ('.$outputlangs->trans('DateFromTo',dol_print_date($date_start, $format, false, $outputlangs),dol_print_date($date_end, $format, false, $outputlangs)).')'; - } - if ($date_start && ! $date_end) - { - $out.= ' ('.$outputlangs->trans('DateFrom',dol_print_date($date_start, $format, false, $outputlangs)).')'; - } - if (! $date_start && $date_end) - { - $out.= ' ('.$outputlangs->trans('DateUntil',dol_print_date($date_end, $format, false, $outputlangs)).')'; - } + if ($date_start && $date_end) + { + $out.= ' ('.$outputlangs->trans('DateFromTo',dol_print_date($date_start, $format, false, $outputlangs),dol_print_date($date_end, $format, false, $outputlangs)).')'; + } + if ($date_start && ! $date_end) + { + $out.= ' ('.$outputlangs->trans('DateFrom',dol_print_date($date_start, $format, false, $outputlangs)).')'; + } + if (! $date_start && $date_end) + { + $out.= ' ('.$outputlangs->trans('DateUntil',dol_print_date($date_end, $format, false, $outputlangs)).')'; + } - return $out; + return $out; } /** @@ -3529,61 +3529,61 @@ function dol_htmloutput_events() */ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepembedded=0) { - global $conf, $langs; + global $conf, $langs; - $ret=''; - $out=''; - $divstart=$divend=''; + $ret=''; + $out=''; + $divstart=$divend=''; - // If inline message with no format, we add it. - if ((empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/
    /i',$out)) - { - $divstart='
    '; - $divend='
    '; - } + // If inline message with no format, we add it. + if ((empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/
    /i',$out)) + { + $divstart='
    '; + $divend='
    '; + } - if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) - { - $langs->load("errors"); - $out.=$divstart; - if (is_array($mesgarray) && count($mesgarray)) - { - foreach($mesgarray as $message) - { - $ret++; - $out.= $langs->trans($message); - if ($ret < count($mesgarray)) $out.= "
    \n"; - } - } - if ($mesgstring) - { - $langs->load("errors"); - $ret++; - $out.= $langs->trans($mesgstring); - } - $out.=$divend; - } + if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) + { + $langs->load("errors"); + $out.=$divstart; + if (is_array($mesgarray) && count($mesgarray)) + { + foreach($mesgarray as $message) + { + $ret++; + $out.= $langs->trans($message); + if ($ret < count($mesgarray)) $out.= "
    \n"; + } + } + if ($mesgstring) + { + $langs->load("errors"); + $ret++; + $out.= $langs->trans($mesgstring); + } + $out.=$divend; + } - if ($out) - { - if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) - { - $return = ''; - } - else - { - $return = $out; - } - } + if ($out) + { + if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) + { + $return = ''; + } + else + { + $return = $out; + } + } - return $return; + return $return; } /** @@ -3599,7 +3599,7 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb */ function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) { - return get_htmloutput_mesg($mesgstring, $mesgarray,'error',$keepembedded); + return get_htmloutput_mesg($mesgstring, $mesgarray,'error',$keepembedded); } /** @@ -3616,45 +3616,45 @@ function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) */ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepembedded=0) { - if (empty($mesgstring) && (! is_array($mesgarray) || count($mesgarray) == 0)) return; + if (empty($mesgstring) && (! is_array($mesgarray) || count($mesgarray) == 0)) return; - $iserror=0; - $iswarning=0; - if (is_array($mesgarray)) - { - foreach($mesgarray as $val) - { - if ($val && preg_match('/class="error"/i',$val)) { $iserror++; break; } - if ($val && preg_match('/class="warning"/i',$val)) { $iswarning++; break; } - } - } - else if ($mesgstring && preg_match('/class="error"/i',$mesgstring)) $iserror++; - else if ($mesgstring && preg_match('/class="warning"/i',$mesgstring)) $iswarning++; - if ($style=='error') $iserror++; - if ($style=='warning') $iswarning++; + $iserror=0; + $iswarning=0; + if (is_array($mesgarray)) + { + foreach($mesgarray as $val) + { + if ($val && preg_match('/class="error"/i',$val)) { $iserror++; break; } + if ($val && preg_match('/class="warning"/i',$val)) { $iswarning++; break; } + } + } + else if ($mesgstring && preg_match('/class="error"/i',$mesgstring)) $iserror++; + else if ($mesgstring && preg_match('/class="warning"/i',$mesgstring)) $iswarning++; + if ($style=='error') $iserror++; + if ($style=='warning') $iswarning++; - if ($iserror || $iswarning) - { - // Remove div from texts - $mesgstring=preg_replace('/<\/div>
    /','
    ',$mesgstring); - $mesgstring=preg_replace('/
    /','',$mesgstring); - $mesgstring=preg_replace('/<\/div>/','',$mesgstring); - // Remove div from texts array - if (is_array($mesgarray)) - { - $newmesgarray=array(); - foreach($mesgarray as $val) - { - $tmpmesgstring=preg_replace('/<\/div>
    /','
    ',$val); - $tmpmesgstring=preg_replace('/
    /','',$tmpmesgstring); - $tmpmesgstring=preg_replace('/<\/div>/','',$tmpmesgstring); - $newmesgarray[]=$tmpmesgstring; - } - $mesgarray=$newmesgarray; - } - print get_htmloutput_mesg($mesgstring,$mesgarray,($iserror?'error':'warning'),$keepembedded); - } - else print get_htmloutput_mesg($mesgstring,$mesgarray,'ok',$keepembedded); + if ($iserror || $iswarning) + { + // Remove div from texts + $mesgstring=preg_replace('/<\/div>
    /','
    ',$mesgstring); + $mesgstring=preg_replace('/
    /','',$mesgstring); + $mesgstring=preg_replace('/<\/div>/','',$mesgstring); + // Remove div from texts array + if (is_array($mesgarray)) + { + $newmesgarray=array(); + foreach($mesgarray as $val) + { + $tmpmesgstring=preg_replace('/<\/div>
    /','
    ',$val); + $tmpmesgstring=preg_replace('/
    /','',$tmpmesgstring); + $tmpmesgstring=preg_replace('/<\/div>/','',$tmpmesgstring); + $newmesgarray[]=$tmpmesgstring; + } + $mesgarray=$newmesgarray; + } + print get_htmloutput_mesg($mesgstring,$mesgarray,($iserror?'error':'warning'),$keepembedded); + } + else print get_htmloutput_mesg($mesgstring,$mesgarray,'ok',$keepembedded); } /** @@ -3670,7 +3670,7 @@ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb */ function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) { - dol_htmloutput_mesg($mesgstring, $mesgarray, 'error', $keepembedded); + dol_htmloutput_mesg($mesgstring, $mesgarray, 'error', $keepembedded); } /** @@ -3687,23 +3687,23 @@ function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) */ function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0) { - // Clean parameters - $order=strtolower($order); + // Clean parameters + $order=strtolower($order); - $sizearray=count($array); - if (is_array($array) && $sizearray>0) - { - foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; - if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp); - else - { - ($case_sensitive) ? natsort($temp) : natcasesort($temp); - if($order!='asc') $temp=array_reverse($temp,TRUE); - } - foreach(array_keys($temp) as $key) (is_numeric($key))? $sorted[]=$array[$key] : $sorted[$key]=$array[$key]; - return $sorted; - } - return $array; + $sizearray=count($array); + if (is_array($array) && $sizearray>0) + { + foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; + if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp); + else + { + ($case_sensitive) ? natsort($temp) : natcasesort($temp); + if($order!='asc') $temp=array_reverse($temp,TRUE); + } + foreach(array_keys($temp) as $key) (is_numeric($key))? $sorted[]=$array[$key] : $sorted[$key]=$array[$key]; + return $sorted; + } + return $array; } @@ -3715,23 +3715,23 @@ function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensiti */ function utf8_check($str) { - // We must use here a binary strlen function (so not dol_strlen) - $strLength = dol_strlen($str); - for ($i=0; $i<$strLength; $i++) - { - if (ord($str[$i]) < 0x80) continue; // 0bbbbbbb - elseif ((ord($str[$i]) & 0xE0) == 0xC0) $n=1; // 110bbbbb - elseif ((ord($str[$i]) & 0xF0) == 0xE0) $n=2; // 1110bbbb - elseif ((ord($str[$i]) & 0xF8) == 0xF0) $n=3; // 11110bbb - elseif ((ord($str[$i]) & 0xFC) == 0xF8) $n=4; // 111110bb - elseif ((ord($str[$i]) & 0xFE) == 0xFC) $n=5; // 1111110b - else return false; // Does not match any model - for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ? - if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) - return false; - } - } - return true; + // We must use here a binary strlen function (so not dol_strlen) + $strLength = dol_strlen($str); + for ($i=0; $i<$strLength; $i++) + { + if (ord($str[$i]) < 0x80) continue; // 0bbbbbbb + elseif ((ord($str[$i]) & 0xE0) == 0xC0) $n=1; // 110bbbbb + elseif ((ord($str[$i]) & 0xF0) == 0xE0) $n=2; // 1110bbbb + elseif ((ord($str[$i]) & 0xF8) == 0xF0) $n=3; // 11110bbb + elseif ((ord($str[$i]) & 0xFC) == 0xF8) $n=4; // 111110bb + elseif ((ord($str[$i]) & 0xFE) == 0xFC) $n=5; // 1111110b + else return false; // Does not match any model + for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ? + if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) + return false; + } + } + return true; } @@ -3744,15 +3744,15 @@ function utf8_check($str) */ function dol_osencode($str) { - global $conf; + global $conf; - $tmp=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 - if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1'; // By default for windows - if (empty($tmp)) $tmp='utf-8'; // By default for other - if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING; + $tmp=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 + if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1'; // By default for windows + if (empty($tmp)) $tmp='utf-8'; // By default for other + if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING; - if ($tmp == 'iso-8859-1') return utf8_decode($str); - return $str; + if ($tmp == 'iso-8859-1') return utf8_decode($str); + return $str; } @@ -3768,35 +3768,35 @@ function dol_osencode($str) */ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') { - global $cache_codes; + global $cache_codes; - // If key empty - if ($key == '') return ''; + // If key empty + if ($key == '') return ''; - // Check in cache - if (isset($cache_codes[$tablename][$key])) // Can be defined to 0 or '' - { - return $cache_codes[$tablename][$key]; // Found in cache - } + // Check in cache + if (isset($cache_codes[$tablename][$key])) // Can be defined to 0 or '' + { + return $cache_codes[$tablename][$key]; // Found in cache + } - $sql = "SELECT ".$fieldid." as id"; - $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; - $sql.= " WHERE ".$fieldkey." = '".$key."'"; - dol_syslog('dol_getIdFromCode sql='.$sql,LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if ($obj) $cache_codes[$tablename][$key]=$obj->id; - else $cache_codes[$tablename][$key]=''; - $db->free($resql); - return $cache_codes[$tablename][$key]; - } - else - { - dol_syslog("dol_getIdFromCode error=".$db->lasterror(),LOG_ERR); - return -1; - } + $sql = "SELECT ".$fieldid." as id"; + $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; + $sql.= " WHERE ".$fieldkey." = '".$key."'"; + dol_syslog('dol_getIdFromCode sql='.$sql,LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $cache_codes[$tablename][$key]=$obj->id; + else $cache_codes[$tablename][$key]=''; + $db->free($resql); + return $cache_codes[$tablename][$key]; + } + else + { + dol_syslog("dol_getIdFromCode error=".$db->lasterror(),LOG_ERR); + return -1; + } } /** @@ -3807,23 +3807,23 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') */ function verifCond($strRights) { - global $user,$conf,$langs; - global $leftmenu; - global $rights; // To export to dol_eval function + global $user,$conf,$langs; + global $leftmenu; + global $rights; // To export to dol_eval function - //print $strRights."
    \n"; - $rights = true; - if ($strRights != '') - { - //$tab_rights = explode('&&', $strRights); - //$i = 0; - //while (($i < count($tab_rights)) && ($rights == true)) { - $str = 'if(!(' . $strRights . ')) { $rights = false; }'; - dol_eval($str); - // $i++; - //} - } - return $rights; + //print $strRights."
    \n"; + $rights = true; + if ($strRights != '') + { + //$tab_rights = explode('&&', $strRights); + //$i = 0; + //while (($i < count($tab_rights)) && ($rights == true)) { + $str = 'if(!(' . $strRights . ')) { $rights = false; }'; + dol_eval($str); + // $i++; + //} + } + return $rights; } /** @@ -3835,13 +3835,13 @@ function verifCond($strRights) */ function dol_eval($s) { - // Only global variables can be changed by eval function and returned to caller - global $langs, $user, $conf; - global $leftmenu; - global $rights; + // Only global variables can be changed by eval function and returned to caller + global $langs, $user, $conf; + global $leftmenu; + global $rights; - //print $s."
    \n"; - eval($s); + //print $s."
    \n"; + eval($s); } /** @@ -3863,29 +3863,24 @@ function dol_validElement($element) */ function picto_from_langcode($codelang) { - global $langs; - - if ($codelang == 'auto') - { - return img_picto_common($langs->trans('AutoDetectLang'), 'flags/int.png'); - } - - $langtocountryflag = array( - 'ar_AR' => '', - 'ca_ES' => 'catalonia', - 'da_DA' => 'dk', - 'fr_CA' => 'mq', - 'sv_SV' => 'se' - ); - - if (isset($langtocountryflag[$codelang])) $flagImage = $langtocountryflag[$codelang]; - else - { - $tmparray = explode('_', $codelang); - $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; - } - - return img_picto_common($codelang, 'flags/'.strtolower($flagImage).'.png'); + $ret=''; + if (! empty($codelang)) + { + if ($codelang == 'auto') $ret=img_picto('',DOL_URL_ROOT.'/theme/common/flags/int.png','',1); + else { + //print $codelang; + $langtocountryflag=array('ar_AR'=>'','ca_ES'=>'catalonia','da_DA'=>'dk','fr_CA'=>'mq','sv_SV'=>'se'); + $tmpcode=''; + if (isset($langtocountryflag[$codelang])) $tmpcode=$langtocountryflag[$codelang]; + else + { + $tmparray=explode('_',$codelang); + $tmpcode=empty($tmparray[1])?$tmparray[0]:$tmparray[1]; + } + if ($tmpcode) $ret.=img_picto($codelang,DOL_URL_ROOT.'/theme/common/flags/'.strtolower($tmpcode).'.png','',1); + } + } + return $ret; } /** @@ -3985,76 +3980,76 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= */ function printCommonFooter($zone='private') { - global $conf; + global $conf; global $micro_start_time; - if ($zone == 'private') print "\n".''."\n"; - else print "\n".''."\n"; + if ($zone == 'private') print "\n".''."\n"; + else print "\n".''."\n"; - if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n"; + if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n"; - // Google Analytics (need Google module) - if (! empty($conf->global->MAIN_GOOGLE_AN_ID)) - { - print "\n"; - print ''."\n"; - } + // Google Analytics (need Google module) + if (! empty($conf->global->MAIN_GOOGLE_AN_ID)) + { + print "\n"; + print ''."\n"; + } - // End of tuning - if (! empty($_SERVER['DOL_TUNING'])) - { - $micro_end_time=dol_microtime_float(true); - print "\n".''."\n"; + // End of tuning + if (! empty($_SERVER['DOL_TUNING'])) + { + $micro_end_time=dol_microtime_float(true); + print "\n".''."\n"; - // Add Xdebug coverage of code - if (defined('XDEBUGCOVERAGE')) { - var_dump(xdebug_get_code_coverage()); - } - } + // Add Xdebug coverage of code + if (defined('XDEBUGCOVERAGE')) { + var_dump(xdebug_get_code_coverage()); + } + } - // If there is some logs in buffer to show - if (count($conf->logbuffer)) - { - print "\n"; - print "\n"; - } + // If there is some logs in buffer to show + if (count($conf->logbuffer)) + { + print "\n"; + print "\n"; + } } @@ -4067,8 +4062,8 @@ function printCommonFooter($zone='private') */ function colorArrayToHex($arraycolor,$colorifnotfound='888888') { - if (! is_array($arraycolor)) return $colorifnotfound; - return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]); + if (! is_array($arraycolor)) return $colorifnotfound; + return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]); } /** @@ -4105,10 +4100,9 @@ function getCurrencySymbol($currency_code) if (! function_exists('getmypid')) { /** - * Return random PID - * Some web hosts disable this php function for security reasons + * Return PID * - * @return int + * @return void */ function getmypid() { diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index d543665a020..19e1f3dd6b3 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2008-2012 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +45,9 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat $h=0; $head[$h][0] = $_SERVER["PHP_SELF"]; $head[$h][1] = $langs->trans("Report"); - dol_fiche_head($head, $hselected, $societe->nom); + $head[$h][2] = 'report'; + + dol_fiche_head($head, $hselected); print '
    '; foreach($moreparam as $key => $value) diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 42c64adf2a9..290e3610625 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -361,7 +361,7 @@ $moreheadjs=empty($conf->use_javascript_ajax)?"":" }); "; -llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECM"),'','','','',$morejs,'',0,0); +llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,'',0,0); // Add sections to manage diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index f1383f3c13f..eed2ac2921a 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -364,6 +364,7 @@ if (! $error && $db->connected && $action == "set") } } } + if ($error) { print "".$langs->trans("ErrorDirDoesNotExists",$main_data_dir); @@ -377,14 +378,14 @@ if (! $error && $db->connected && $action == "set") { //ODT templates require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); - $srcroot='./doctemplates'; + $srcroot=$main_dir.'/install/doctemplates'; $destroot=$main_data_dir.'/doctemplates'; $docs=array('thirdparties' => 'thirdparty', 'proposals' => 'proposal', 'orders' => 'order', 'invoices' => 'invoice'); - foreach($docs as $dir => $file) + foreach($docs as $cursordir => $cursorfile) { - $src=$srcroot.'/thirdparties/template_'.$file.'.odt'; - $dirodt=$destroot.'/'.$dir; - $dest=$dirodt.'/template_'.$file.'.odt'; + $src=$srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt'; + $dirodt=$destroot.'/'.$cursordir; + $dest=$dirodt.'/template_'.$cursorfile.'.odt'; dol_mkdir($dirodt); $result=dol_copy($src,$dest,0,0); diff --git a/htdocs/langs/tr_TR/main.lang b/htdocs/langs/tr_TR/main.lang index 8273038e53b..edf0bae6e61 100755 --- a/htdocs/langs/tr_TR/main.lang +++ b/htdocs/langs/tr_TR/main.lang @@ -1,661 +1,660 @@ -/* - * Language code: tr_TR - * Manually generated - * Generation date 2012-07-04 21:40:00 - */ - -// START - Lines generated manually (2012-07-04 21:40:00). -// Reference language: en_US – main - -CHARSET=UTF-8 -DIRECTION=ltr -SeparatorDecimal=. -SeparatorThousand=, -FormatDateShort=%d/%m/%Y -FormatDateShortJava=dd/mm/yyyy -FormatDateShortJQuery=dd/mm/yy -FormatHourShort=%I:%M%p -FormatHourShortDuration=%H:%M -FormatDateTextShort=%b%d%Y -FormatDateText=%D%B%Y -FormatDateHourShort=%d/%m/%Y %I:%M%p -FormatDateHourTextShort=%b %d,%Y,%I:%M %p -FormatDateHourText=%D %B %Y,%I:%M %p -DatabaseConnection=Veritabanı bağlantısı -NoError=Hata yok -Error=Hata -ErrorFieldRequired='%s' Alanı gereklidir. -ErrorFieldFormat=%s' Alanı değeri hatalı. -ErrorFileDoesNotExists='%s' Dosyası yok -ErrorFailedToOpenFile='%s' Dosyası açılamadı -ErrorCanNotCreateDir='%s' Dizini oluşturulamıyor -ErrorCanNotReadDir='%s' Dizini okunamıyor -ErrorConstantNotDefined=%s Parametresi tanımlı değil -ErrorUnknown=Bilinmeyen hata -ErrorSQL=SQL Hatası -ErrorLogoFileNotFound='%s' Logo dosyası bulunamadı -ErrorGoToGlobalSetup='Firma/Kuruluş' ayarlarına giderek düzeltiniz. -ErrorGoToModuleSetup=Bunu düzeltmek için Modül Kurulumuna git -ErrorFailedToSendMail=Posta gönderilemedi (gönderen) -ErrorAttachedFilesDisabled=Bu sunucuda dosya ekleme engellenmiştir -ErrorFileNotUploaded=Dosya gönderilemedi. Boyutun izin verilen ençok dosya boyutunu aşmadığını denetleyin, bu dizinde yeterli boş alan olmalı ve aynı isimde başka bir dosya olmamalı. -ErrorInternalErrorDetected=Hata algılandı -ErrorNoRequestRan=Hiçbir istek yürütülmedi -ErrorWrongHostParameter=Yanlış ana parametre -ErrorYourCountryIsNotDefined=Ülkeniz tanımlı değil. Giriş-Kur-Düzenle ye git ve formu yeniden gönder. -ErrorRecordIsUsedByChild=Bu kayıt silinemedi. Bu kayıt en az bir alt kayıt tarafından kullanılmaktadır. -ErrorWrongValue=Yanlış değer -ErrorWrongValueForParameterX=Parametresi %s için yanlış değer -ErrorNoRequestInError=Hatalı istek yok -ErrorServiceUnavailableTryLater=Hizmet şu an için kullanılamıyor. Daha sonra yeniden deneyin. -ErrorDuplicateField=Benzersiz bir alanda yinelenen değer -ErrorSomeErrorWereFoundRollbackIsDone=Bazı hatalar bulundu. Değişikler geri alındı. -ErrorConfigParameterNotDefined=Parametre %s Dolibarr yapılandırma dosyasında conf.php tanımlı değil. -ErrorCantLoadUserFromDolibarrDatabase=Dolibarr veritabanında kullanıcı %s bulunamadı. -ErrorNoVATRateDefinedForSellerCountry=Hata, ülke '%s' için herhangi bir KDV oranı tanımlanmamış. -ErrorNoSocialContributionForSellerCountry=Hata, ülke %s için herhangi bir sosyal güvenlik primi türü tanımlanmış. -ErrorFailedToSaveFile=Hata, dosya kaydedilemedi. -ErrorOnlyPngJpgSupported=Hata yalnızca .Png ve .jpg görüntü dosya formatları desteklenmektedir. -ErrorImageFormatNotSupported=PHP bu biçimdeki görüntüleri dönüştürecek işlevleri desteklemez. -SeeAlso=See also %s -BackgroundColorByDefault=Varsayılan arkaplan rengi -FileWasNotUploaded= Bu ekleme için bir dosya seçildi ama henüz gönderilmedi. Bunun için “Dosya ekle” ye tıklayın. -NbOfEntries=Girişlerin sayısı -GoToWikiHelpPage=Çevrimiçi yardım oku (Internet erişimi gerekir) -GoToHelpPage=Yardım oku -RecordSaved=Kayıt kaydedildi -LevelOfFeature=Özellik düzeyleri -NotDefined=Tanımlanmamış -DefinedAndHasThisValue=Tanımlanmış ve şuna değer atanmıştır -IsNotDefined=tanımlanmamış -DolibarrInHttpAuthenticationSoPasswordUseless= Yapılandırma dosyası conf.phpda Dolibarr kimlik doğrulama modu %s a ayarlanmıştır.
    Bu demektir ki; veritabanı parolası Dolibarr dışıdır, yani bu alanı değiştirmek hiçbir etki yaratmaz. -Administrator=Yönetici -Undefined=Tanımlanmamış -PasswordForgotten=Parolanızı mı unuttunuz? -SeeAbove=Yukarı bak -HomeArea=Giriş alanı -LastConnexion=Son bağlantı -PreviousConnexion=Önceki bağlantı -ConnectedOnMultiCompany=Çevreye bağlanmış -ConnectedSince=Bağlantı başlangıcı -AuthenticationMode=Doğrulama biçimi -RequestedUrl=İstenen URL -DatabaseTypeManager=Veritabanı türü yöneticisi -RequestLastAccess=Son veritabanı erişimi isteği -RequestLastAccessInError=Son veritabanı erişimi istek hatası -ReturnCodeLastAccessInError=Hatalı son veritabanı erişim kodunu göster -InformationLastAccessInError=Hatalı son veritabanı erişimi bilgisi -DolibarrHasDetectedError=Dolibarr teknik bir hata algıladı -InformationToHelpDiagnose=Bu bilgiler teşhis etmeye yardımcı olabilir -MoreInformation=Daha fazla bilgi -NotePublic=Not (Genel) -NotePrivate=Not (özel) -PrecisionUnitIsLimitedToXDecimals=Dolibarr birim fiyatlar için hassasiyeti %s ondalık olarak sınırlandırmıştır. -DoTest=Deneme -ToFilter=Süzgeç -WarningYouHaveAtLeastOneTaskLate=Uyarı, gecikme toleransını aşan en az bir var. -yes=evet -Yes=Evet -no=hayır -No=Hayır -All=Hepsi -Home=Giriş -Help=Yardım -OnlineHelp=Çevrimiçi yardım -PageWiki=Wiki sayfası -Always=Daima -Never=Asla -Under=altında -Period=Dönem -PeriodEndDate=Dönem için Bitiş tarihi -Activate=Etkinleştir -Activated=Etkin -Closed=Kapalı -Closed2=Kapalı -Enabled=Etkin -Disable=Engelli -Disabled=Engelli -Add=Ekle -AddLink=Bağlantı ekle -Update=Güncelle -AddActionToDo=Yapılacak eylem ekle -AddActionDone=Bitmiş eylem ekle -Close=Kapat -Close2=Kapat -Confirm=Onayla -ConfirmSendCardByMail=Gerçekten bu kartı posta ile %s a göndermek istiyor musunuz? -Delete=Sil -Remove=Kaldır -Resiliate=Sonlandır -Cancel=İptal -Modify=Değiştir -Edit=Düzenle -Validate=Doğrula -ToValidate=Doğrulanacak -Save=Kaydet -SaveAs=Farklı kaydet -TestConnection=Test bağlantısı -ToClone=Klonla -ConfirmClone=Klonlamak istediğiniz verileri seçin: -NoCloneOptionsSpecified= Klonlanacak hiçbir veri tanımlanmamış. -Of=ile ilgili -CopyOf=Kopyası -Show=Göster -ShowCardHere=Kartı göster -Search=Ara -SearchOf=Ara -Valid=Geçerli -Approve=Onayla -ReOpen=Yeniden aç -Upload=Dosya gönder -Select=Seç -Choose=Seç -ChooseLangage=Lütfen dilinizi seçin -Resize=Yeniden boyutlandır -Recenter=Yeniden ortala -Author=Yazar -User=Kullanıcı -Users=Kullanıcılar -Group=Grup -Groups=Gruplar -Password=Parola -PasswordRetype=Parolanızı yeniden yazın -NoteSomeFeaturesAreDisabled=Bu demoda bir çok özelliğin/modülün engelli olduğuna dikkat edin. -Name=Ad -Person=Kişi -Parameter=Parametre -Parameters=Parametreler -Value=Değer -GlobalValue=Genel değer -PersonalValue=Kişisel değer -NewValue=Yeni değer -CurrentValue=Geçerli değer -Code=Kod -Type=Tür -Language=Dil -MultiLanguage=Çoklu-dil -Note=Not -CurrentNote=Geçerli not -Title=Başlık -Label=Etiket -RefOrLabel=Ref. veya etiket -Info=Log -Family=Aile -Description=Açıklama -Designation=Açıklama -Model=Model -DefaultModel=Varsayılan model -Action=Eylem -About=Hakkında -Number=Sayı -NumberByMonth=Aya göre sayı -AmountByMonth=Aylık Tutarı -Numero=Sayı -Limit=Sınır -Limits=Sınırlar -DevelopmentTeam=Geliştirme Ekibi -Logout=Çıkış -Connection=Bağlan -Setup=Kurulum -Alert=Uyarı -Previous=Önceki -Next=Sonraki -Cards=Kartlar -Card=Kart -Now=Şimdi -Date=Tarih -DateStart=Başlangıç tarihi -DateEnd=Bitiş tarih -DateCreation=Oluşturma tarihi -DateModification=Değiştirme tarihi -DateModificationShort=Değiş. tarihi -DateLastModification=Son değiştirme tarihi -DateValidation=Doğrulama tarihi -DateClosing=Kapanış tarihi -DateDue=Vade tarihi -DateValue=Satış tarihi (valör) -DateValueShort=Satış tarihi -DateOperation=İşlem tarihi -DateOperationShort=İşl. Tarih -DateLimit=Sınır tarihi -DateRequest=İstek tarihi -DateProcess=İşleme tarihi -DatePlanShort=Planlana tarih -DateRealShort=Gerç.Tarih -DateBuild=Oluşturma tarihi raporu -DatePayment=Ödeme tarihi -DurationYear=yıl -DurationMonth=ay -DurationWeek=hafta -DurationDay=gün -DurationYears=yıl -DurationMonths=ay -DurationWeeks=hafta -DurationDays=gün -Year=Yıl -Month=Ay -Week=Hafta -Day=Gün -Hour=Saat -Minute=Dakika -Second=Saniye -Years=Yıl -Months=Ay -Days=Gün -days=gün -Hours=Saat -Minutes=Dakika -Seconds=Saniye -Today=Bugün -Yesterday=Dün -Tomorrow=Yarın -Quadri=Çeyrek -MonthOfDay=Ayın günü -HourShort=H -Rate=Oran -Bytes=Bayt -KiloBytes=Kilobayt -MegaBytes=Megabayt -GigaBytes=Gigabayt -TeraBytes=Terabayt -b=b. -Kb=Kb -Mb=Mb -Gb=Gb -Tb=Tb -Cut=Kes -Copy=Kopyala -Paste=Yapıştır -Default=Varsayılan -DefaultValue=Varsayılan değer -DefaultGlobalValue=Genel değer -Price=Fiyat -UnitPrice=Birim fiyat -UnitPriceHT=Birim fiyat (net) -UnitPriceTTC=Birim fiyat -PriceU=B.F. -PriceUHT=B.F. (net) -PriceUTTC=B.F. -Amount=Tutar -AmountInvoice=Fatura tutarı -AmountPayment=Ödeme tutarı -AmountHTShort=Tutar (net) -AmountTTCShort=Miktarı (KDV dahil) -AmountHT=Tutar (KDV hariç) -AmountTTC=Miktarı (KDV dahil) -AmountVAT=KDV tutarı -AmountLT1ES=RE Tutarı -AmountLT2ES=IRPF Tutarı -AmountTotal=Toplam tutar -AmountAverage=Ortalama tutar -PriceQtyHT=Bu miktar için fiyat (KDV hariç) -PriceQtyMinHT=Enaz miktar fiyatı (KDV hariç) -PriceQtyTTC=Bu miktar için fiyat (KDV dahil) -PriceQtyMinTTC=Enaz miktar fiyatı (KDV dahil) -Percentage=Yüzde -Total=Toplam -SubTotal=Aratoplam -TotalHTShort=Toplam (Net) -TotalTTCShort=Toplam (KDV dahil) -TotalHT=Toplam (KDV hariç) -TotalTTC=Toplam (KDV dahil) -TotalTTCToYourCredit=Alacağınız için toplam (KDV dahil) -TotalVAT=Toplam KDV -TotalLT1ES=Toplam RE -TotalLT2ES=Toplam IRPF -IncludedVAT=KDV dahil -HT= KDV hariç -TTC=KDV dahil -VAT=KDV -LT1ES=RE -LT2ES=IRPF -VATRate=KDV Oranı -Average=Ortalama -Sum=Toplam -Delta=Değişim oranı -Module=Modül -Option=Seçenek -List=Liste -FullList=Tüm liste -Statistics=İstatistikler -OtherStatistics=Diğer istatistikler -Status=Durum -Ref=Ref. -RefSupplier=Ref. tedarikçi -RefPayment=Ref. ödeme -CommercialProposals=Ticari teklifler -Comment=Yorum -Comments=Yorumlar -ActionsToDo=Yapılacak Eylemler -ActionsDone=Biten eylemler -ActionsToDoShort=Yapılacaklar -ActionsRunningshort=Başladı -ActionsDoneShort=Yapıldı -ActionNotApplicable=Uygulanamaz -ActionRunningNotStarted=Başlamadı -ActionRunningShort=Başladı -ActionDoneShort=Bitti -CompanyFoundation=Firma/Kuruluş -ContactsForCompany=Firma Kişileri -ContactsAddressesForCompany=Bu üçüncü partinin kişleri/adresleri -AddressesForCompany=Bu üçüncü partinin adresleri -ActionsOnCompany=Bu üçüncü parti hakkındaki eylemler -ActionsOnMember=Bu üye hakkındaki eylemler -NActions=%s eylemleri -NActionsLate=%s geç -Filter=Süzgeç -RemoveFilter=Süzgeç kaldır -ChartGenerated=Grafik oluşturuldu -ChartNotGenerated=Grafik oluşturulmadı -GeneratedOn=%s Oluşturuldu -Generate=Oluştur -Duration=Süre -TotalDuration=Toplam süre -Summary=Özet -MyBookmarks=Yerimlerim -OtherInformationsBoxes=Diğer bilgi kutuları -DolibarrBoard=Dolibarr kurulu -DolibarrStateBoard=İstatistikler -DolibarrWorkBoard=İş görevleri kurulu -Available=Mevcut -NotYetAvailable=Henüz mevcut değil -NotAvailable=Uygun değil -Popularity=Popülerlik -Categories=Kategoriler -Category=Kategori -By=Tarafından -From=Kimden -to=kadar -and=ve -or=veya -Other=Diğer -Others=Diğerleri -OtherInformations=Diğer Bilgiler -Quantity=Miktar -Qty=Mik -ChangedBy=Tarafından değiştirildi -ReCalculate=Yeniden hesapla -ResultOk=Başarılı -ResultKo=Başarısız -Reporting=Raporlama -Reportings=Raporlamalar -Draft=Taslak -Drafts=Taslaklar -Validated=Doğrulanmış -Opened=Açık -New=Yeni -Discount=İndirim -Unknown=Bilinmeyen -General=Genel -Size=Boyut -Received=Alınan -Paid=Ödenen -Topic=Konu -ByCompanies=Firmalara göre -ByUsers=Kullanıcılara göre -Links=Bağlantılar -Link=Bağlantı -Receipts=Makbuzlar -Rejects=Kusurlular -Preview=Önizleme -NextStep=Sonraki adım -PreviousStep=Önceki adım -Datas=Veriler -None=Hiçbiri -NoneF=Hiçbiri -Late=Geç -Photo=Resim -Photos=Resimler -AddPhoto=Resim ekle -Login=Kullanıcı -CurrentLogin=Geçerli kullanıcı -January=Ocak -February=Şubat -March=Mart -April=Nisan -May=Mayıs -June=Haziran -July=Temmuz -August=Ağustos -September=Eylül -October=Ekim -November=Kasım -December=Aralık -JanuaryMin=Ara -FebruaryMin=Şub -MarchMin=Mar -AprilMin=Nis -MayMin=May -JuneMin=Haz -JulyMin=Tem -AugustMin=Ağu -SeptemberMin=Eyl -OctoberMin=Eki -NovemberMin=Kas -DecemberMin=Ara -Month01=ocak -Month02=şubat -Month03=mart -Month04=nisan -Month05=mayıs -Month06=haziran -Month07=temmuz -Month08=ağustos -Month09=eylül -Month10=ekim -Month11=kasım -Month12=aralık -MonthShort01=oca -MonthShort02=şub -MonthShort03=mar -MonthShort04=nis -MonthShort05=may -MonthShort06=haz -MonthShort07=tem -MonthShort08=ağu -MonthShort09=eyl -MonthShort10=eki -MonthShort11=kas -MonthShort12=ara -AttachedFiles=Ekli dosya ve belgeler -FileTransferComplete=Dosya başarıyla gönderildi -DateFormatYYYYMM=YYYY-AA -DateFormatYYYYMMDD=YYYY-AA-GG -DateFormatYYYYMMDDHHMM=YYYY-AA-GG SS:SS -ReportName=Rapor Adı -ReportPeriod=Rapor dönemi -ReportDescription=Açıklama -Report=Rapor -Keyword=Anahtar kelime -Legend=Gösterge -FillTownFromZip=İli Posta Kodundan (zip) doldurun -ShowLog=Günlüğü (logu) göster -File=Dosya -Files=Dosyalar -NotAllowed=İzin verilmez -ReadPermissionNotAllowed=Okuma izni yok -AmountInCurrency=Para birimi tutarı %s -Example=Örnek -Examples=Örnekler -NoExample=Örnek yok -FindBug=Hata bul -NbOfThirdParties=Üçüncü parti sayısı -NbOfCustomers=Müşterilerin sayısı -NbOfLines=Satır sayısı -NbOfObjects=Nesne sayısı -NbOfReferers=Yönlendirenlerin sayısı -Referers=Referanslar -TotalQuantity=Toplam miktar -DateFromTo=%s den %s e kadar -DateFrom=%s den -DateUntil=%s e Kadar -Check=Denetle -Internal=İç -External=Dış -Internals=İçler -Externals=Dışlar -Warning=Uyarı -Warnings=Uyarılar -BuildPDF=PDF oluştur -RebuildPDF=Yeniden PDF oluştur -BuildDoc=Doc oluştur -RebuildDoc=Yeniden Doc oluştur -Entity=Varlık -Entities=Varlıklar -EventLogs=Günlükler (loglar) -CustomerPreview=Müşteri önizleme -SupplierPreview=Tedarikçi önizleme -AccountancyPreview=Muhasebe önizleme -ShowCustomerPreview=Müşteri önizlemeyi göster -ShowSupplierPreview=Tedarikçi önizlemeyi göster -ShowAccountancyPreview=Muhasebe önizlemeyi göster -ShowProspectPreview=Aday önizlemeyi göster -RefCustomer=Müşteri Ref. -Currency=Para birimi -InfoAdmin=Yöneticiler için bilgi -Undo=Geri al -Redo=Yinele -ExpandAll=Tümünü genişlet -UndoExpandAll=Genişletmeyi geri al -Reason=Neden -FeatureNotYetSupported=Özellik henüz desteklenmiyor -CloseWindow=Pencereyi kapat -Question=Soru -Response=Yanıt -Priority=Öncelik -SendByMail=E-posta ile gönder -MailSentBy=E-posta ile gönderildi -TextUsedInTheMessageBody=Mesaj gövdesinde yazı kullanıldı. -SendAcknowledgementByMail=Alındı bilgisini e-posta ile gönder. -NoEMail=E-posta yok -Owner=Sahibi -DetectedVersion=Belirlenen sürüm -FollowingConstantsWillBeSubstituted=Aşağıdaki değişmezler uygun değerlerin yerine konacaktır. -Refresh=Yenile -BackToList=Listeye dön -GoBack=Geri dön -CanBeModifiedIfOk=Geçerliyse değiştirilebilir -CanBeModifiedIfKo=Geçerli değilse değiştirilebilir -RecordModifiedSuccessfully=Kayıt başarıyla değiştirildi -AutomaticCode=Otomatik kod -NotManaged=Başarılamadı -FeatureDisabled=Özellik devre dışı -MoveBox=Kutu %s i taşı -Offered=Önerilen -NotEnoughPermissions=Bu eylem için izininiz yok -SessionName=Oturum adı -Method=Yöntem -Receive=Al -PartialWoman=Kısmi -PartialMan=Kısmi -TotalWoman=Toplam -TotalMan=Toplam -NeverReceived=Hiç alınmadı -Canceled=Vazgeçildi -YouCanChangeValuesForThisListFromDictionnarySetup=Bu listedeki değerleri Kurulum->Sözlük kurulumu menüsünden değiştirebilirsiniz -Color=Renk -Documents=Bağlı dosyalar -DocumentsNb=Bağlı dosyalar (%s) -Documents2=Belgeler -BuildDocuments=Oluşturulan belgeler -UploadDisabled=Gönderme engelli -MenuECM=Belgeler -MenuAWStats=AWStats -MenuMembers=Üyeler -MenuAgendaGoogle=Google gündemi -ThisLimitIsDefinedInSetup=Dolibarr sınırı (Giriş->Kurulum->Güvenlik menüsü):%s Kb, PHP sınırı:%s Kb -NoFileFound=Hiçbir belge bu dizine kaydedilmedi -CurrentUserLanguage=Geçerli dil -CurrentTheme=Geçerli tema -DisabledModules=Engelli modüller -For=İçin -ForCustomer=Müşteriler için -Signature=İmza -HidePassword= Komutu gizli parola ile göster -UnHidePassword=Gerçek komutu açık parola ile göster -Root=Kök -Informations=Bilgi -Page=Sayfa -Notes=Notlar -AddNewLine=Yeni satır ekle -AddFile=Dosya ekle -ListOfFiles=Varolan dosyaların listesi -FreeZone=Serbest metin -CloneMainAttributes=Nesneyi ana öznitelikleri ile klonla -PDFMerge=PDF Birleştir -Merge=Birleştir -PrintContentArea=Sayfa yazdırılacak ana içerik alanını göster -NoMenu=Alt menü yok -WarningYouAreInMaintenanceMode=Uyarı, bakım modundasınız, şu anda uygulamayı kullanmak için yalnızca %s girişine izin veriliyor. -CoreErrorTitle=Sistem hatası -CoreErrorMessage=Üzgünüz, bir hata oluştu. Günlükleri kontrol edin veya sistem yöneticinize başvurun. -CreditCard=Kredi kartı -FieldsWithAreMandatory=%s olan alanları zorunludur -FieldsWithIsForPublic= Üyelerin genel listelerinde %s olan alanlar gösterilir. Bunu istemiyorsanız, “genel” kutusundan işareti kaldırın. -AccordingToGeoIPDatabase=(GeoIP dönüşümüne göre) -Line=Satır -NotSupported=Desteklenmez -RequiredField=Gerekli alan -Result=Sonuç -ToTest=Denem -ValidateBefore=Bu özelliği kullanmadan önce kart doğrulanmalıdır -Visibility=Görünürlük -Private=Özel -Hidden=Gizli -Resources=Kaynaklar -Source=Kaynak -Prefix=Önek -Before=Önce -After=Sonra -IPAddress=IP adresi -Frequency=Frekans -IM=Anlık mesajlaşma -NewAttribute=Yeni bir öznitelik -AttributeCode=Öznitelik kodu -OptionalFieldsSetup=Ekstra öznitelik ayarları -URLPhoto=Fotoğrafın/logonun url si -SetLinkToThirdParty=Başka bir üçüncü parti bağlantısı -CreateDraft=Taslak oluştur -ClickToEdit=Düzenlemek için tıklayın -ObjectDeleted=Nesne %s silindi -ByCountry=Ülkeye göre -ByTown=İlçeye göre -ByDate=Tarihe göre -ByMonthYear=Ay/yıl olarak -ByYear=Yıla göre -ByMonth=Aya göre -ByDay=Güne göre -BySalesRepresentative=Satış temsilcisine göre - -# Week day -Monday=Pazartesi -Tuesday=Salı -Wednesday=Çarşamba -Thursday=Perşembe -Friday=Cuma -Saturday=Cumartesi -Sunday=Pazar -MondayMin=Pt -TuesdayMin=Sa -WednesdayMin=Ça -ThursdayMin=Pe -FridayMin=Cu -SaturdayMin=Ct -SundayMin=Pa -Day1=Pazartesi -Day2=Salı -Day3=Çarşamba -Day4=Perşembe -Day5=Cuma -Day6=Cumartesi -Day0=Pazar -ShortMonday=Pt -ShortTuesday=Sa -ShortWednesday=Ça -ShortThursday=Pe -ShortFriday=Cu -ShortSaturday=Ct -ShortSunday=Pa -FONTFORPDF=DejaVuSans -FONTSIZEFORPDF=8 -WelcomeString=% %s Dolibarr yapılandırma dosyasında conf.php tanımlı değil. +ErrorCantLoadUserFromDolibarrDatabase=Dolibarr veritabanında kullanıcı %s bulunamadı. +ErrorNoVATRateDefinedForSellerCountry=Hata, ülke '%s' için herhangi bir KDV oranı tanımlanmamış. +ErrorNoSocialContributionForSellerCountry=Hata, ülke %s için herhangi bir sosyal güvenlik primi türü tanımlanmış. +ErrorFailedToSaveFile=Hata, dosya kaydedilemedi. +ErrorOnlyPngJpgSupported=Hata yalnızca .Png ve .jpg görüntü dosya formatları desteklenmektedir. +ErrorImageFormatNotSupported=PHP bu biçimdeki görüntüleri dönüştürecek işlevleri desteklemez. +SeeAlso=See also %s +BackgroundColorByDefault=Varsayılan arkaplan rengi +FileWasNotUploaded= Bu ekleme için bir dosya seçildi ama henüz gönderilmedi. Bunun için “Dosya ekle” ye tıklayın. +NbOfEntries=Girişlerin sayısı +GoToWikiHelpPage=Çevrimiçi yardım oku (Internet erişimi gerekir) +GoToHelpPage=Yardım oku +RecordSaved=Kayıt kaydedildi +LevelOfFeature=Özellik düzeyleri +NotDefined=Tanımlanmamış +DefinedAndHasThisValue=Tanımlanmış ve şuna değer atanmıştır +IsNotDefined=tanımlanmamış +DolibarrInHttpAuthenticationSoPasswordUseless= Yapılandırma dosyası conf.phpda Dolibarr kimlik doğrulama modu %s a ayarlanmıştır.
    Bu demektir ki; veritabanı parolası Dolibarr dışıdır, yani bu alanı değiştirmek hiçbir etki yaratmaz. +Administrator=Yönetici +Undefined=Tanımlanmamış +PasswordForgotten=Parolanızı mı unuttunuz? +SeeAbove=Yukarı bak +HomeArea=Giriş alanı +LastConnexion=Son bağlantı +PreviousConnexion=Önceki bağlantı +ConnectedOnMultiCompany=Çevreye bağlanmış +ConnectedSince=Bağlantı başlangıcı +AuthenticationMode=Doğrulama biçimi +RequestedUrl=İstenen URL +DatabaseTypeManager=Veritabanı türü yöneticisi +RequestLastAccess=Son veritabanı erişimi isteği +RequestLastAccessInError=Son veritabanı erişimi istek hatası +ReturnCodeLastAccessInError=Hatalı son veritabanı erişim kodunu göster +InformationLastAccessInError=Hatalı son veritabanı erişimi bilgisi +DolibarrHasDetectedError=Dolibarr teknik bir hata algıladı +InformationToHelpDiagnose=Bu bilgiler teşhis etmeye yardımcı olabilir +MoreInformation=Daha fazla bilgi +NotePublic=Not (Genel) +NotePrivate=Not (özel) +PrecisionUnitIsLimitedToXDecimals=Dolibarr birim fiyatlar için hassasiyeti %s ondalık olarak sınırlandırmıştır. +DoTest=Deneme +ToFilter=Süzgeç +WarningYouHaveAtLeastOneTaskLate=Uyarı, gecikme toleransını aşan en az bir var. +yes=evet +Yes=Evet +no=hayır +No=Hayır +All=Hepsi +Home=Giriş +Help=Yardım +OnlineHelp=Çevrimiçi yardım +PageWiki=Wiki sayfası +Always=Daima +Never=Asla +Under=altında +Period=Dönem +PeriodEndDate=Dönem için Bitiş tarihi +Activate=Etkinleştir +Activated=Etkin +Closed=Kapalı +Closed2=Kapalı +Enabled=Etkin +Disable=Engelli +Disabled=Engelli +Add=Ekle +AddLink=Bağlantı ekle +Update=Güncelle +AddActionToDo=Yapılacak eylem ekle +AddActionDone=Bitmiş eylem ekle +Close=Kapat +Close2=Kapat +Confirm=Onayla +ConfirmSendCardByMail=Gerçekten bu kartı posta ile %s a göndermek istiyor musunuz? +Delete=Sil +Remove=Kaldır +Resiliate=Sonlandır +Cancel=İptal +Modify=Değiştir +Edit=Düzenle +Validate=Doğrula +ToValidate=Doğrulanacak +Save=Kaydet +SaveAs=Farklı kaydet +TestConnection=Test bağlantısı +ToClone=Klonla +ConfirmClone=Klonlamak istediğiniz verileri seçin: +NoCloneOptionsSpecified= Klonlanacak hiçbir veri tanımlanmamış. +Of=ile ilgili +CopyOf=Kopyası +Show=Göster +ShowCardHere=Kartı göster +Search=Ara +SearchOf=Ara +Valid=Geçerli +Approve=Onayla +ReOpen=Yeniden aç +Upload=Dosya gönder +Select=Seç +Choose=Seç +ChooseLangage=Lütfen dilinizi seçin +Resize=Yeniden boyutlandır +Recenter=Yeniden ortala +Author=Yazar +User=Kullanıcı +Users=Kullanıcılar +Group=Grup +Groups=Gruplar +Password=Parola +PasswordRetype=Parolanızı yeniden yazın +NoteSomeFeaturesAreDisabled=Bu demoda bir çok özelliğin/modülün engelli olduğuna dikkat edin. +Name=Ad +Person=Kişi +Parameter=Parametre +Parameters=Parametreler +Value=Değer +GlobalValue=Genel değer +PersonalValue=Kişisel değer +NewValue=Yeni değer +CurrentValue=Geçerli değer +Code=Kod +Type=Tür +Language=Dil +MultiLanguage=Çoklu-dil +Note=Not +CurrentNote=Geçerli not +Title=Başlık +Label=Etiket +RefOrLabel=Ref. veya etiket +Info=Log +Family=Aile +Description=Açıklama +Designation=Açıklama +Model=Model +DefaultModel=Varsayılan model +Action=Eylem +About=Hakkında +Number=Sayı +NumberByMonth=Aya göre sayı +AmountByMonth=Aylık Tutarı +Numero=Sayı +Limit=Sınır +Limits=Sınırlar +DevelopmentTeam=Geliştirme Ekibi +Logout=Çıkış +Connection=Bağlan +Setup=Kurulum +Alert=Uyarı +Previous=Önceki +Next=Sonraki +Cards=Kartlar +Card=Kart +Now=Şimdi +Date=Tarih +DateStart=Başlangıç tarihi +DateEnd=Bitiş tarih +DateCreation=Oluşturma tarihi +DateModification=Değiştirme tarihi +DateModificationShort=Değiş. tarihi +DateLastModification=Son değiştirme tarihi +DateValidation=Doğrulama tarihi +DateClosing=Kapanış tarihi +DateDue=Vade tarihi +DateValue=Satış tarihi (valör) +DateValueShort=Satış tarihi +DateOperation=İşlem tarihi +DateOperationShort=İşl. Tarih +DateLimit=Sınır tarihi +DateRequest=İstek tarihi +DateProcess=İşleme tarihi +DatePlanShort=Planlana tarih +DateRealShort=Gerç.Tarih +DateBuild=Oluşturma tarihi raporu +DatePayment=Ödeme tarihi +DurationYear=yıl +DurationMonth=ay +DurationWeek=hafta +DurationDay=gün +DurationYears=yıl +DurationMonths=ay +DurationWeeks=hafta +DurationDays=gün +Year=Yıl +Month=Ay +Week=Hafta +Day=Gün +Hour=Saat +Minute=Dakika +Second=Saniye +Years=Yıl +Months=Ay +Days=Gün +days=gün +Hours=Saat +Minutes=Dakika +Seconds=Saniye +Today=Bugün +Yesterday=Dün +Tomorrow=Yarın +Quadri=Çeyrek +MonthOfDay=Ayın günü +HourShort=H +Rate=Oran +Bytes=Bayt +KiloBytes=Kilobayt +MegaBytes=Megabayt +GigaBytes=Gigabayt +TeraBytes=Terabayt +b=b. +Kb=Kb +Mb=Mb +Gb=Gb +Tb=Tb +Cut=Kes +Copy=Kopyala +Paste=Yapıştır +Default=Varsayılan +DefaultValue=Varsayılan değer +DefaultGlobalValue=Genel değer +Price=Fiyat +UnitPrice=Birim fiyat +UnitPriceHT=Birim fiyat (net) +UnitPriceTTC=Birim fiyat +PriceU=B.F. +PriceUHT=B.F. (net) +PriceUTTC=B.F. +Amount=Tutar +AmountInvoice=Fatura tutarı +AmountPayment=Ödeme tutarı +AmountHTShort=Tutar (net) +AmountTTCShort=Miktarı (KDV dahil) +AmountHT=Tutar (KDV hariç) +AmountTTC=Miktarı (KDV dahil) +AmountVAT=KDV tutarı +AmountLT1ES=RE Tutarı +AmountLT2ES=IRPF Tutarı +AmountTotal=Toplam tutar +AmountAverage=Ortalama tutar +PriceQtyHT=Bu miktar için fiyat (KDV hariç) +PriceQtyMinHT=Enaz miktar fiyatı (KDV hariç) +PriceQtyTTC=Bu miktar için fiyat (KDV dahil) +PriceQtyMinTTC=Enaz miktar fiyatı (KDV dahil) +Percentage=Yüzde +Total=Toplam +SubTotal=Aratoplam +TotalHTShort=Toplam (Net) +TotalTTCShort=Toplam (KDV dahil) +TotalHT=Toplam (KDV hariç) +TotalTTC=Toplam (KDV dahil) +TotalTTCToYourCredit=Alacağınız için toplam (KDV dahil) +TotalVAT=Toplam KDV +TotalLT1ES=Toplam RE +TotalLT2ES=Toplam IRPF +IncludedVAT=KDV dahil +HT= KDV hariç +TTC=KDV dahil +VAT=KDV +LT1ES=RE +LT2ES=IRPF +VATRate=KDV Oranı +Average=Ortalama +Sum=Toplam +Delta=Değişim oranı +Module=Modül +Option=Seçenek +List=Liste +FullList=Tüm liste +Statistics=İstatistikler +OtherStatistics=Diğer istatistikler +Status=Durum +Ref=Ref. +RefSupplier=Ref. tedarikçi +RefPayment=Ref. ödeme +CommercialProposals=Ticari teklifler +Comment=Yorum +Comments=Yorumlar +ActionsToDo=Yapılacak Eylemler +ActionsDone=Biten eylemler +ActionsToDoShort=Yapılacaklar +ActionsRunningshort=Başladı +ActionsDoneShort=Yapıldı +ActionNotApplicable=Uygulanamaz +ActionRunningNotStarted=Başlamadı +ActionRunningShort=Başladı +ActionDoneShort=Bitti +CompanyFoundation=Firma/Kuruluş +ContactsForCompany=Firma Kişileri +ContactsAddressesForCompany=Bu üçüncü partinin kişleri/adresleri +AddressesForCompany=Bu üçüncü partinin adresleri +ActionsOnCompany=Bu üçüncü parti hakkındaki eylemler +ActionsOnMember=Bu üye hakkındaki eylemler +NActions=%s eylemleri +NActionsLate=%s geç +Filter=Süzgeç +RemoveFilter=Süzgeç kaldır +ChartGenerated=Grafik oluşturuldu +ChartNotGenerated=Grafik oluşturulmadı +GeneratedOn=%s Oluşturuldu +Generate=Oluştur +Duration=Süre +TotalDuration=Toplam süre +Summary=Özet +MyBookmarks=Yerimlerim +OtherInformationsBoxes=Diğer bilgi kutuları +DolibarrBoard=Dolibarr kurulu +DolibarrStateBoard=İstatistikler +DolibarrWorkBoard=İş görevleri kurulu +Available=Mevcut +NotYetAvailable=Henüz mevcut değil +NotAvailable=Uygun değil +Popularity=Popülerlik +Categories=Kategoriler +Category=Kategori +By=Tarafından +From=Başlama +to=Bitiş +and=ve +or=veya +Other=Diğer +Others=Diğerleri +OtherInformations=Diğer Bilgiler +Quantity=Miktar +Qty=Mik +ChangedBy=Tarafından değiştirildi +ReCalculate=Yeniden hesapla +ResultOk=Başarılı +ResultKo=Başarısız +Reporting=Raporlama +Reportings=Raporlamalar +Draft=Taslak +Drafts=Taslaklar +Validated=Doğrulanmış +Opened=Açık +New=Yeni +Discount=İndirim +Unknown=Bilinmeyen +General=Genel +Size=Boyut +Received=Alınan +Paid=Ödenen +Topic=Konu +ByCompanies=Firmalara göre +ByUsers=Kullanıcılara göre +Links=Bağlantılar +Link=Bağlantı +Receipts=Makbuzlar +Rejects=Kusurlular +Preview=Önizleme +NextStep=Sonraki adım +PreviousStep=Önceki adım +Datas=Veriler +None=Hiçbiri +NoneF=Hiçbiri +Late=Geç +Photo=Resim +Photos=Resimler +AddPhoto=Resim ekle +Login=Kullanıcı +CurrentLogin=Geçerli kullanıcı +January=Ocak +February=Şubat +March=Mart +April=Nisan +May=Mayıs +June=Haziran +July=Temmuz +August=Ağustos +September=Eylül +October=Ekim +November=Kasım +December=Aralık +JanuaryMin=Ara +FebruaryMin=Şub +MarchMin=Mar +AprilMin=Nis +MayMin=May +JuneMin=Haz +JulyMin=Tem +AugustMin=Ağu +SeptemberMin=Eyl +OctoberMin=Eki +NovemberMin=Kas +DecemberMin=Ara +Month01=ocak +Month02=şubat +Month03=mart +Month04=nisan +Month05=mayıs +Month06=haziran +Month07=temmuz +Month08=ağustos +Month09=eylül +Month10=ekim +Month11=kasım +Month12=aralık +MonthShort01=oca +MonthShort02=şub +MonthShort03=mar +MonthShort04=nis +MonthShort05=may +MonthShort06=haz +MonthShort07=tem +MonthShort08=ağu +MonthShort09=eyl +MonthShort10=eki +MonthShort11=kas +MonthShort12=ara +AttachedFiles=Ekli dosya ve belgeler +FileTransferComplete=Dosya başarıyla gönderildi +DateFormatYYYYMM=YYYY-AA +DateFormatYYYYMMDD=YYYY-AA-GG +DateFormatYYYYMMDDHHMM=YYYY-AA-GG SS:SS +ReportName=Rapor Adı +ReportPeriod=Rapor dönemi +ReportDescription=Açıklama +Report=Rapor +Keyword=Anahtar kelime +Legend=Gösterge +FillTownFromZip=İli Posta Kodundan (zip) doldurun +ShowLog=Günlüğü (logu) göster +File=Dosya +Files=Dosyalar +NotAllowed=İzin verilmez +ReadPermissionNotAllowed=Okuma izni yok +AmountInCurrency=Para birimi: %s +Example=Örnek +Examples=Örnekler +NoExample=Örnek yok +FindBug=Hata bul +NbOfThirdParties=Üçüncü parti sayısı +NbOfCustomers=Müşterilerin sayısı +NbOfLines=Satır sayısı +NbOfObjects=Nesne sayısı +NbOfReferers=Yönlendirenlerin sayısı +Referers=Referanslar +TotalQuantity=Toplam miktar +DateFromTo=%s den %s e kadar +DateFrom=%s den +DateUntil=%s e Kadar +Check=Denetle +Internal=İç +External=Dış +Internals=İçler +Externals=Dışlar +Warning=Uyarı +Warnings=Uyarılar +BuildPDF=PDF oluştur +RebuildPDF=Yeniden PDF oluştur +BuildDoc=Doc oluştur +RebuildDoc=Yeniden Doc oluştur +Entity=Varlık +Entities=Varlıklar +EventLogs=Günlükler (loglar) +CustomerPreview=Müşteri önizleme +SupplierPreview=Tedarikçi önizleme +AccountancyPreview=Muhasebe önizleme +ShowCustomerPreview=Müşteri önizlemeyi göster +ShowSupplierPreview=Tedarikçi önizlemeyi göster +ShowAccountancyPreview=Muhasebe önizlemeyi göster +ShowProspectPreview=Aday önizlemeyi göster +RefCustomer=Müşteri Ref. +Currency=Para birimi +InfoAdmin=Yöneticiler için bilgi +Undo=Geri al +Redo=Yinele +ExpandAll=Tümünü genişlet +UndoExpandAll=Genişletmeyi geri al +Reason=Neden +FeatureNotYetSupported=Özellik henüz desteklenmiyor +CloseWindow=Pencereyi kapat +Question=Soru +Response=Yanıt +Priority=Öncelik +SendByMail=E-posta ile gönder +MailSentBy=E-posta ile gönderildi +TextUsedInTheMessageBody=Mesaj gövdesinde yazı kullanıldı. +SendAcknowledgementByMail=Alındı bilgisini e-posta ile gönder. +NoEMail=E-posta yok +Owner=Sahibi +DetectedVersion=Belirlenen sürüm +FollowingConstantsWillBeSubstituted=Aşağıdaki değişmezler uygun değerlerin yerine konacaktır. +Refresh=Yenile +BackToList=Listeye dön +GoBack=Geri dön +CanBeModifiedIfOk=Geçerliyse değiştirilebilir +CanBeModifiedIfKo=Geçerli değilse değiştirilebilir +RecordModifiedSuccessfully=Kayıt başarıyla değiştirildi +AutomaticCode=Otomatik kod +NotManaged=Başarılamadı +FeatureDisabled=Özellik devre dışı +MoveBox=Kutu %s i taşı +Offered=Önerilen +NotEnoughPermissions=Bu eylem için izininiz yok +SessionName=Oturum adı +Method=Yöntem +Receive=Al +PartialWoman=Kısmi +PartialMan=Kısmi +TotalWoman=Toplam +TotalMan=Toplam +NeverReceived=Hiç alınmadı +Canceled=Vazgeçildi +YouCanChangeValuesForThisListFromDictionnarySetup=Bu listedeki değerleri Kurulum->Sözlük kurulumu menüsünden değiştirebilirsiniz +Color=Renk +Documents=Bağlı dosyalar +DocumentsNb=Bağlı dosyalar (%s) +Documents2=Belgeler +BuildDocuments=Oluşturulan belgeler +UploadDisabled=Gönderme engelli +MenuECM=Belgeler +MenuAWStats=AWStats +MenuMembers=Üyeler +MenuAgendaGoogle=Google gündemi +ThisLimitIsDefinedInSetup=Dolibarr sınırı (Giriş->Kurulum->Güvenlik menüsü):%s Kb, PHP sınırı:%s Kb +NoFileFound=Hiçbir belge bu dizine kaydedilmedi +CurrentUserLanguage=Geçerli dil +CurrentTheme=Geçerli tema +DisabledModules=Engelli modüller +For=İçin +ForCustomer=Müşteriler için +Signature=İmza +HidePassword= Komutu gizli parola ile göster +UnHidePassword=Gerçek komutu açık parola ile göster +Root=Kök +Informations=Bilgi +Page=Sayfa +Notes=Notlar +AddNewLine=Yeni satır ekle +AddFile=Dosya ekle +ListOfFiles=Varolan dosyaların listesi +FreeZone=Serbest metin +CloneMainAttributes=Nesneyi ana öznitelikleri ile klonla +PDFMerge=PDF Birleştir +Merge=Birleştir +PrintContentArea=Sayfa yazdırılacak ana içerik alanını göster +NoMenu=Alt menü yok +WarningYouAreInMaintenanceMode=Uyarı, bakım modundasınız, şu anda uygulamayı kullanmak için yalnızca %s girişine izin veriliyor. +CoreErrorTitle=Sistem hatası +CoreErrorMessage=Üzgünüz, bir hata oluştu. Günlükleri kontrol edin veya sistem yöneticinize başvurun. +CreditCard=Kredi kartı +FieldsWithAreMandatory=%s olan alanları zorunludur +FieldsWithIsForPublic= Üyelerin genel listelerinde %s olan alanlar gösterilir. Bunu istemiyorsanız, “genel” kutusundan işareti kaldırın. +AccordingToGeoIPDatabase=(GeoIP dönüşümüne göre) +Line=Satır +NotSupported=Desteklenmez +RequiredField=Gerekli alan +Result=Sonuç +ToTest=Denem +ValidateBefore=Bu özelliği kullanmadan önce kart doğrulanmalıdır +Visibility=Görünürlük +Private=Özel +Hidden=Gizli +Resources=Kaynaklar +Source=Kaynak +Prefix=Önek +Before=Önce +After=Sonra +IPAddress=IP adresi +Frequency=Frekans +IM=Anlık mesajlaşma +NewAttribute=Yeni bir öznitelik +AttributeCode=Öznitelik kodu +OptionalFieldsSetup=Ekstra öznitelik ayarları +URLPhoto=Fotoğrafın/logonun url si +SetLinkToThirdParty=Başka bir üçüncü parti bağlantısı +CreateDraft=Taslak oluştur +ClickToEdit=Düzenlemek için tıklayın +ObjectDeleted=Nesne %s silindi +ByCountry=Ülkeye göre +ByTown=İlçeye göre +ByDate=Tarihe göre +ByMonthYear=Ay/yıl olarak +ByYear=Yıla göre +ByMonth=Aya göre +ByDay=Güne göre +BySalesRepresentative=Satış temsilcisine göre + +# Week day +Monday=Pazartesi +Tuesday=Salı +Wednesday=Çarşamba +Thursday=Perşembe +Friday=Cuma +Saturday=Cumartesi +Sunday=Pazar +MondayMin=Pt +TuesdayMin=Sa +WednesdayMin=Ça +ThursdayMin=Pe +FridayMin=Cu +SaturdayMin=Ct +SundayMin=Pa +Day1=Pazartesi +Day2=Salı +Day3=Çarşamba +Day4=Perşembe +Day5=Cuma +Day6=Cumartesi +Day0=Pazar +ShortMonday=Pt +ShortTuesday=Sa +ShortWednesday=Ça +ShortThursday=Pe +ShortFriday=Cu +ShortSaturday=Ct +ShortSunday=Pa diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d703039489b..bde9bb72bfa 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -541,7 +541,8 @@ class Project extends CommonObject if (!$error) { - $this->db->commit(); + $this->statut=1; + $this->db->commit(); return 1; } else diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index f5ea9ef0426..70cdceffff1 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -314,7 +314,7 @@ if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confi } else { - $object->id=$result; + $object->fetch($result); // Load new object $action='edit'; $comefromclone=true; } @@ -494,7 +494,9 @@ else // Customer print ''.$langs->trans("Company").''; - print $form->select_company($object->societe->id,'socid','',1,1); + $text=$form->select_company($object->societe->id,'socid','',1,1); + $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty"); + print $form->textwithtooltip($text.' '.img_help(),$texthelp,1); print ''; // Visibility