2
0
forked from Wavyzz/dolibarr

Fix: miscellaneous bugs

This commit is contained in:
Laurent Destailleur
2014-10-03 12:15:21 +02:00
parent bc1279ccfa
commit 166853dd56
6 changed files with 164 additions and 119 deletions

View File

@@ -547,128 +547,135 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti
* Salaries
*/
print '<tr><td colspan="4">'.$langs->trans("Salaries").'</td></tr>';
$sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user";
$sql.= " WHERE p.entity = ".$conf->entity;
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 u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm";
$sql.= " ORDER BY u.firstname";
dol_syslog("get payment salaries");
$result=$db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
if ($conf->salaries->enabled)
{
$num = $db->num_rows($result);
$var=true;
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
print '<tr><td colspan="4">'.$langs->trans("Salaries").'</td></tr>';
$sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user";
$sql.= " WHERE p.entity = ".$conf->entity;
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$total_ht -= $obj->amount;
$total_ttc -= $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
$sql.= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm";
$sql.= " ORDER BY u.firstname";
$var = !$var;
print "<tr ".$bc[$var]."><td>&nbsp;</td>";
dol_syslog("get payment salaries");
$result=$db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
{
$num = $db->num_rows($result);
$var=true;
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
print "<td>".$langs->trans("Salaries")." <a href=\"".DOL_URL_ROOT."/compta/salaries/index.php?filtre=s.fk_user=".$obj->fk_user."\">".$obj->firstname." ".$obj->lastname."</a></td>\n";
$total_ht -= $obj->amount;
$total_ttc -= $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price(-$obj->amount).'</td>';
print '<td align="right">'.price(-$obj->amount).'</td>';
print '</tr>';
$i++;
}
}
else
{
$var = !$var;
print "<tr ".$bc[$var]."><td>&nbsp;</td>";
print '<td colspan="3">'.$langs->trans("None").'</td>';
print '</tr>';
}
$var = !$var;
print "<tr ".$bc[$var]."><td>&nbsp;</td>";
print "<td>".$langs->trans("Salaries")." <a href=\"".DOL_URL_ROOT."/compta/salaries/index.php?filtre=s.fk_user=".$obj->fk_user."\">".$obj->firstname." ".$obj->lastname."</a></td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price(-$obj->amount).'</td>';
print '<td align="right">'.price(-$obj->amount).'</td>';
print '</tr>';
$i++;
}
}
else
{
$var = !$var;
print "<tr ".$bc[$var]."><td>&nbsp;</td>";
print '<td colspan="3">'.$langs->trans("None").'</td>';
print '</tr>';
}
}
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>';
}
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>';
/*
* Dunning
*/
* Donation
*/
print '<tr><td colspan="4">'.$langs->trans("Donation").'</td></tr>';
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND fk_statut=2";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY p.societe, p.firstname, p.lastname";
$sql.= " ORDER BY p.societe, p.firstname, p.lastname";
dol_syslog("get dunning");
$result=$db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
if ($conf->donation->enabled)
{
$num = $db->num_rows($result);
$var=true;
$i = 0;
if ($num)
print '<tr><td colspan="4">'.$langs->trans("Donation").'</td></tr>';
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND fk_statut=2";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
$sql.= " ORDER BY p.societe, p.firstname, p.lastname, dm";
dol_syslog("get dunning");
$result=$db->query($sql);
$subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result)
{
while ($i < $num)
$num = $db->num_rows($result);
$var=true;
$i = 0;
if ($num)
{
$obj = $db->fetch_object($result);
while ($i < $num)
{
$obj = $db->fetch_object($result);
$total_ht += $obj->amount;
$total_ttc += $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
$total_ht += $obj->amount;
$total_ttc += $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
$var = !$var;
print "<tr ".$bc[$var]."><td>&nbsp;</td>";
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/compta/dons/list.php?search_company=".$obj->nom."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->nom. " ".$obj->firstname." ".$obj->lastname."</a></td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price($obj->amount).'</td>';
print '<td align="right">'.price($obj->amount).'</td>';
print '</tr>';
$i++;
}
}
else
{
$var = !$var;
print "<tr ".$bc[$var]."><td>&nbsp;</td>";
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/compta/dons/list.php?search_company=".$obj->nom."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->nom. " ".$obj->firstname." ".$obj->lastname."</a></td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price($obj->amount).'</td>';
print '<td align="right">'.price($obj->amount).'</td>';
print '<td colspan="3">'.$langs->trans("None").'</td>';
print '</tr>';
$i++;
}
}
else
{
$var = !$var;
print "<tr ".$bc[$var]."><td>&nbsp;</td>";
print '<td colspan="3">'.$langs->trans("None").'</td>';
print '</tr>';
dol_print_error($db);
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price($subtotal_ttc).'</td>';
print '</tr>';
}
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price($subtotal_ttc).'</td>';
print '</tr>';
/*
* VAT

View File

@@ -39,6 +39,7 @@ $contactid = GETPOST('id','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'contact', $contactid,'');
$search_firstlast_only=GETPOST("search_firstlast_only");
$search_lastname=GETPOST("search_lastname");
$search_firstname=GETPOST("search_firstname");
$search_societe=GETPOST("search_societe");
@@ -51,8 +52,8 @@ $search_fax=GETPOST("search_fax");
$search_email=GETPOST("search_email");
$search_skype=GETPOST("search_skype");
$search_priv=GETPOST("search_priv");
$search_categ = GETPOST("search_categ",'int');
$search_status = GETPOST("search_status",'int');
$search_categ=GETPOST("search_categ",'int');
$search_statu=GETPOST("search_status",'int');
if ($search_status=='') $search_status=1; // always display activ customer first
@@ -74,7 +75,12 @@ $offset = $limit * $page;
$langs->load("companies");
$titre = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
if ($type == "c" || $type=="p")
if ($type == "p")
{
$titre.=' ('.$langs->trans("ThirdPartyProspects").')';
$urlfiche="card.php";
}
if ($type == "c")
{
$titre.=' ('.$langs->trans("ThirdPartyCustomers").')';
$urlfiche="card.php";
@@ -92,6 +98,7 @@ else if ($type == "o")
if (GETPOST('button_removefilter'))
{
$search_firstlast_only="";
$search_lastname="";
$search_firstname="";
$search_societe="";
@@ -154,6 +161,9 @@ else
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_firstlast_only) {
$sql .= natural_search(array('p.lastname','p.firstname'), $search_firstlast_only);
}
if ($search_lastname) { // filter on lastname
$sql .= natural_search('p.lastname', $search_lastname);
}
@@ -213,7 +223,7 @@ else if ($type == "p") // filtre sur type
}
if ($sall)
{
$sql .= natural_search(array('p.lastname', 'p.firstname', 'p.email'), $sall);
$sql .= natural_search(array('p.lastname', 'p.firstname', 'p.email', 's.nom'), $sall);
}
if (! empty($socid))
{
@@ -277,9 +287,12 @@ if ($result)
if ($sall)
{
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname")." ".$langs->trans("or")." ".$langs->trans("EMail")."): ".$sall;
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("ThirdParty")." ".$langs->trans("or")." ".$langs->trans("EMail")."): ".$sall;
}
if ($search_firstlast_only)
{
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname")."): ".$search_firstlast_only;
}
print '<table class="liste" width="100%">';
// Ligne des titres

View File

@@ -100,7 +100,7 @@ function dol_hash($chain,$type=0)
* @param string $features Features to check (it must be module name. Examples: 'societe', 'contact', 'produit&service', 'produit|service', ...)
* @param int $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
* @param string $dbtablename 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)
* @param string $feature2 Feature to check, second level of permission (optional)
* @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
* @param Canvas $objcanvas Object canvas
@@ -140,7 +140,7 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
// Check read permission from module
$readok=1; $nbko=0;
foreach ($featuresarray as $feature)
foreach ($featuresarray as $feature) // first we check nb of test ko
{
if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($feature,$listofmodules)) // If limits on modules for external users, module must be into list of modules for external users
{
@@ -174,11 +174,17 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
}
else if (! empty($feature2)) // This should be used for future changes
{
$tmpreadok=1;
foreach($feature2 as $subfeature)
{
if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $readok=0; $nbko++; }
else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $readok=0; $nbko++; }
else { $readok=1; break; } // Break is to bypass second test if the first is ok
if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; }
else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; }
else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok
}
if (! $tmpreadok) // We found a test on feature that is ko
{
$readok=0; // All tests are ko (we manage here the and, the or will be managed later using $nbko).
$nbko++;
}
}
else if (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is for old permissions

View File

@@ -624,7 +624,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
}
// Contacts
$newmenu->add("/contact/list.php?leftmenu=contacts", (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")), 0, $user->rights->societe->contact->lire, '', $mainmenu, 'contacts');
$newmenu->add("/societe/index.php?leftmenu=thirdparties", (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ThirdParty") : $langs->trans("ContactsAddresses")), 0, $user->rights->societe->contact->lire, '', $mainmenu, 'contacts');
$newmenu->add("/contact/card.php?leftmenu=contacts&amp;action=create", (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")), 1, $user->rights->societe->contact->creer);
$newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire);
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire);

View File

@@ -397,7 +397,7 @@ YouMustCreateContactFirst=You must create emails contacts for third party first
ListSuppliersShort=List of suppliers
ListProspectsShort=List of prospects
ListCustomersShort=List of customers
ThirdPartiesArea=Third parties area
ThirdPartiesArea=Third parties and contact area
LastModifiedThirdParties=Last %s modified third parties
UniqueThirdParties=Total of unique third parties
InActivity=Open
@@ -410,3 +410,5 @@ OutstandingBillReached=Reached max. for outstanding bill
MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for supplier code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0.
LeopardNumRefModelDesc=The code is free. This code can be modified at any time.
ManagingDirectors=Manager(s) name (CEO, director, president...)
SearchThirdparty=Search thirdparty
SearchContact=Search contact

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Charles-Fr Benke <charles.fr@benke.fr>
*
@@ -64,7 +64,7 @@ print '<form method="post" action="'.DOL_URL_ROOT.'/societe/societe.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("Search").'</th></tr>';
print '<th colspan="3">'.$langs->trans("SearchThirdparty").'</th></tr>';
print "<tr ".$bc[false]."><td>";
print '<label for="search_nom_only">'.$langs->trans("Name").'</label>:</td><td><input class="flat" type="text" size="14" name="search_nom_only" id="search_nom_only"></td>';
print '<td rowspan="'.$rowspan.'"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
@@ -79,9 +79,26 @@ print "<tr ".$bc[false]."><td ".$bc[false].">";
print '<label for="search_all">'.$langs->trans("Other").'</label>:</td><td '.$bc[false].'><input class="flat" type="text" size="14" name="search_all" id="search_all"></td>';
//print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
print '</tr>';
print "</table></form><br>";
/*
* Search contact
*/
$rowspan=2;
if (! empty($conf->barcode->enabled)) $rowspan++;
print '<form method="post" action="'.DOL_URL_ROOT.'/contact/list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("SearchContact").'</th></tr>';
print "<tr ".$bc[false]."><td>";
print '<label for="search_nom_only">'.$langs->trans("Name").'</label>:</td><td><input class="flat" type="text" size="14" name="search_firstlast_only" id="search_firstlast_only"></td>';
print '<td rowspan="'.$rowspan.'"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
print "<tr ".$bc[false]."><td ".$bc[false].">";
print '<label for="search_all">'.$langs->trans("Other").'</label>:</td><td '.$bc[false].'><input class="flat" type="text" size="14" name="contactname" id="contactname"></td>';
//print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
print '</tr>';
print "</table></form><br>";
/*
* Statistics area
@@ -121,7 +138,7 @@ print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2))
{
print '<tr><td align="center" colspan="2">';
print '<tr '.$bc[0].'><td align="center" colspan="2">';
$dataseries=array();
if (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array('label'=>$langs->trans("Prospects"),'data'=>round($third['prospect']));
if (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array('label'=>$langs->trans("Customers"),'data'=>round($third['customer']));
@@ -135,19 +152,19 @@ else
{
if (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
{
$statstring = "<tr $bc[0]>";
$statstring = "<tr ".$bc[0].">";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/list.php">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>';
$statstring.= "</tr>";
}
if (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
{
$statstring.= "<tr $bc[1]>";
$statstring.= "<tr ".$bc[1].">";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/comm/list.php">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>';
$statstring.= "</tr>";
}
if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS))
{
$statstring2 = "<tr $bc[0]>";
$statstring2 = "<tr ".$bc[0].">";
$statstring2.= '<td><a href="'.DOL_URL_ROOT.'/fourn/list.php">'.$langs->trans("Suppliers").'</a></td><td align="right">'.round($third['supplier']).'</td>';
$statstring2.= "</tr>";
}