Merge branch 'develop' of github.com:Dolibarr/dolibarr into develop

This commit is contained in:
Maxime Kohlhaas 2014-07-31 15:19:20 +02:00
commit b2ad8c74a5
6 changed files with 191 additions and 205 deletions

View File

@ -57,7 +57,7 @@ if (! $result > 0) { dol_print_error('',$user->error); exit; }
$user->getrights(); $user->getrights();
print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
if (! isset($argv[1])) { // Check parameters if (! isset($argv[1])) { // Check parameters
print "Usage: ".$script_file." param1 param2 ...\n"; print "Usage: ".$script_file." param1 param2 ...\n";
exit(-1); exit(-1);

View File

@ -2333,7 +2333,7 @@ function dol_print_error($db='',$error='')
else // Mode CLI else // Mode CLI
{ {
$out.='> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; $out.='> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n";
$syslog.="pid=".getmypid(); $syslog.="pid=".dol_getmypid();
} }
if (is_object($db)) if (is_object($db))
@ -4742,17 +4742,19 @@ function dol_set_focus($selector)
} }
if (! function_exists('getmypid'))
{
/** /**
* Return random PID * Return getmypid() or random PID when function is disabled
* Some web hosts disable this php function for security reasons * Some web hosts disable this php function for security reasons
* and sometimes we can't redeclare function
* *
* @return int * @return int
*/ */
function getmypid() function dol_getmypid()
{ {
if (! function_exists('getmypid')) {
return rand(1,32768); return rand(1,32768);
} else {
return getmypid();
} }
} }

View File

@ -11427,7 +11427,7 @@ class TCPDF {
} }
$seed .= uniqid('', true); $seed .= uniqid('', true);
$seed .= rand(); $seed .= rand();
$seed .= getmypid(); $seed .= dol_getmypid();
$seed .= __FILE__; $seed .= __FILE__;
$seed .= $this->bufferlen; $seed .= $this->bufferlen;
if (isset($_SERVER['REMOTE_ADDR'])) { if (isset($_SERVER['REMOTE_ADDR'])) {

View File

@ -1358,7 +1358,7 @@ class TCPDF_STATIC {
} }
$seed .= uniqid('', true); $seed .= uniqid('', true);
$seed .= rand(); $seed .= rand();
$seed .= getmypid(); $seed .= dol_getmypid();
$seed .= __FILE__; $seed .= __FILE__;
if (isset($_SERVER['REMOTE_ADDR'])) { if (isset($_SERVER['REMOTE_ADDR'])) {
$seed .= $_SERVER['REMOTE_ADDR']; $seed .= $_SERVER['REMOTE_ADDR'];

View File

@ -128,6 +128,7 @@ if ($id > 0 || ! empty($ref))
print '</div>'; print '</div>';
if ($user->rights->facture->lire) {
$sql = "SELECT s.nom, s.rowid as socid, s.code_client,"; $sql = "SELECT s.nom, s.rowid as socid, s.code_client,";
$sql.= " f.rowid as facid, f.facnumber, f.total as total_ht,"; $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht,";
$sql.= " f.datef, f.paye, f.fk_statut as statut,"; $sql.= " f.datef, f.paye, f.fk_statut as statut,";
@ -156,14 +157,13 @@ if ($id > 0 || ! empty($ref))
//$sql.= $db->plimit($conf->liste_limit +1, $offset); //$sql.= $db->plimit($conf->liste_limit +1, $offset);
dol_syslog('margin:tabs:productMargins.php', LOG_DEBUG); dol_syslog('margin:tabs:productMargins.php', LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;id=$object->id",$sortfield,$sortorder,'',0,0,''); print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;id=$object->id",$sortfield,$sortorder,'',0,0,'');
$i = 0; $i = 0;
print "<table class=\"noborder\" width=\"100%\">"; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;id=".$object->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;id=".$object->id,'',$sortfield,$sortorder);
@ -186,26 +186,21 @@ if ($id > 0 || ! empty($ref))
$cumul_qty = 0; $cumul_qty = 0;
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
if ($num > 0) if ($num > 0) {
{
$var=True; $var=True;
while ($i < $num /*&& $i < $conf->liste_limit*/) while ($i < $num /*&& $i < $conf->liste_limit*/) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var=!$var; $var=!$var;
if ($objp->marge < 0) if ($objp->marge < 0) {
{
$marginRate = ($objp->buying_price != 0)?-1*(100 * $objp->marge / $objp->buying_price):'' ; $marginRate = ($objp->buying_price != 0)?-1*(100 * $objp->marge / $objp->buying_price):'' ;
$markRate = ($objp->selling_price != 0)?-1*(100 * $objp->marge / $objp->selling_price):'' ; $markRate = ($objp->selling_price != 0)?-1*(100 * $objp->marge / $objp->selling_price):'' ;
} } else {
else
{
$marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ;
$markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ;
} }
print "<tr ".$bc[$var].">"; print '<tr '.$bc[$var].'>';
print '<td>'; print '<td>';
$invoicestatic->id=$objp->facid; $invoicestatic->id=$objp->facid;
$invoicestatic->ref=$objp->facnumber; $invoicestatic->ref=$objp->facnumber;
@ -235,40 +230,34 @@ if ($id > 0 || ! empty($ref))
// affichage totaux marges // affichage totaux marges
$var=!$var; $var=!$var;
$totalMargin = $cumul_vente - $cumul_achat; $totalMargin = $cumul_vente - $cumul_achat;
if ($totalMargin < 0) if ($totalMargin < 0) {
{
$marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):'';
} } else {
else
{
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td colspan=4>'.$langs->trans('TotalMargin')."</td>"; print '<td colspan=4>'.$langs->trans('TotalMargin')."</td>";
print "<td align=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n"; print '<td align="right">'.price($cumul_vente, null, null, null, null, $rounding)."</td>\n";
print "<td align=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n"; print '<td align="right">'.price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
print "<td align=\"right\">".price($cumul_qty, null, null, null, null, $rounding)."</td>\n"; print '<td align="right">'.price($cumul_qty, null, null, null, null, $rounding)."</td>\n";
print "<td align=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n"; print '<td align="right">'.price($totalMargin, null, null, null, null, $rounding)."</td>\n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n"; print '<td align="right">'.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (! empty($conf->global->DISPLAY_MARK_RATES)) if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n"; print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
print '<td align="right">&nbsp;</td>'; print '<td align="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
}
else
{
dol_print_error($db);
}
print "</table>"; print "</table>";
print '<br>'; print '<br>';
} else {
dol_print_error($db);
}
$db->free($result); $db->free($result);
} }
} }
else } else {
{
dol_print_error(); dol_print_error();
} }

View File

@ -120,6 +120,7 @@ if ($id > 0 || ! empty($ref))
print '</div>'; print '</div>';
if ($user->rights->facture->lire) {
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,";
$sql.= " f.facnumber, f.total as total_ht,"; $sql.= " f.facnumber, f.total as total_ht,";
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty"; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty";
@ -138,14 +139,13 @@ if ($id > 0 || ! empty($ref))
$sql.= $db->plimit($conf->liste_limit +1, $offset); $sql.= $db->plimit($conf->liste_limit +1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num,0,''); print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num,0,'');
$i = 0; $i = 0;
print "<table class=\"noborder\" width=\"100%\">"; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","","&amp;id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","","&amp;id=".$product->id,'',$sortfield,$sortorder);
@ -157,15 +157,13 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;id=".$product->id,'align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
if ($num > 0) if ($num > 0) {
{
$var=True; $var=True;
while ($i < $num && $i < $conf->liste_limit) while ($i < $num && $i < $conf->liste_limit) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">"; print '<tr '.$bc[$var].'>';
print '<td>'; print '<td>';
$invoicestatic->id=$objp->facid; $invoicestatic->id=$objp->facid;
$invoicestatic->ref=$objp->facnumber; $invoicestatic->ref=$objp->facnumber;
@ -173,27 +171,24 @@ if ($id > 0 || ! empty($ref))
print "</td>\n"; print "</td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'</a></td>';
print "<td>".$objp->code_client."</td>\n"; print "<td>".$objp->code_client."</td>\n";
print "<td align=\"center\">"; print '<td align="center">';
print dol_print_date($db->jdate($objp->datef),'day')."</td>"; print dol_print_date($db->jdate($objp->datef),'day')."</td>";
print "<td align=\"center\">".$objp->qty."</td>\n"; print '<td align="center">'.$objp->qty."</td>\n";
print "<td align=\"right\">".price($objp->total_ht)."</td>\n"; print '<td align="right">'.price($objp->total_ht)."</td>\n";
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>'; print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
} }
}
else
{
dol_print_error($db);
}
print "</table>"; print "</table>";
print '<br>'; print '<br>';
} else {
dol_print_error($db);
}
$db->free($result); $db->free($result);
} }
} }
else } else {
{
dol_print_error(); dol_print_error();
} }