diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 12fac084d55..19054bfd7c9 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -547,128 +547,135 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti * Salaries */ -print ''.$langs->trans("Salaries").''; -$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 ''.$langs->trans("Salaries").''; + $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 " "; + 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 "".$langs->trans("Salaries")." fk_user."\">".$obj->firstname." ".$obj->lastname."\n"; + $total_ht -= $obj->amount; + $total_ttc -= $obj->amount; + $subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; - if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount).''; - print ''.price(-$obj->amount).''; - print ''; - $i++; - } - } - else - { - $var = !$var; - print " "; - print ''.$langs->trans("None").''; - print ''; - } + $var = !$var; + print " "; + + print "".$langs->trans("Salaries")." fk_user."\">".$obj->firstname." ".$obj->lastname."\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; + print ''; + $i++; + } + } + else + { + $var = !$var; + print " "; + print ''.$langs->trans("None").''; + print ''; + } + } + else + { + dol_print_error($db); + } + print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''.price(-$subtotal_ht).''; + print ''.price(-$subtotal_ttc).''; + print ''; } -else -{ - dol_print_error($db); -} -print ''; -if ($modecompta == 'CREANCES-DETTES') - print ''.price(-$subtotal_ht).''; -print ''.price(-$subtotal_ttc).''; -print ''; + /* - * Dunning -*/ + * Donation + */ -print ''.$langs->trans("Donation").''; -$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 ''.$langs->trans("Donation").''; + $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 " "; + + print "".$langs->trans("Donation")." nom."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->nom. " ".$obj->firstname." ".$obj->lastname."\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''.price($obj->amount).''; + print ''.price($obj->amount).''; + print ''; + $i++; + } + } + else + { $var = !$var; print " "; - - print "".$langs->trans("Donation")." nom."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->nom. " ".$obj->firstname." ".$obj->lastname."\n"; - - if ($modecompta == 'CREANCES-DETTES') print ''.price($obj->amount).''; - print ''.price($obj->amount).''; + print ''.$langs->trans("None").''; print ''; - $i++; } } else { - $var = !$var; - print " "; - print ''.$langs->trans("None").''; - print ''; + dol_print_error($db); } + print ''; + if ($modecompta == 'CREANCES-DETTES') + print ''.price($subtotal_ht).''; + print ''.price($subtotal_ttc).''; + print ''; } -else -{ - dol_print_error($db); -} -print ''; -if ($modecompta == 'CREANCES-DETTES') - print ''.price($subtotal_ht).''; -print ''.price($subtotal_ttc).''; -print ''; /* * VAT diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 11eb366e98c..c65e9601e53 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -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 ''; // Ligne des titres diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index c8cccefda7f..87dfcf1367b 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -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 diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c703847128f..b6fde307110 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -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&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); diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 1b2ea17215b..06c350039a3 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -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 \ No newline at end of file diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index e6a251a2d78..740a6157809 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Charles-Fr Benke * @@ -64,7 +64,7 @@ print '
'; print ''; print '
'; print ''; -print ''; +print ''; print "'; print ''; @@ -79,9 +79,26 @@ print "'; //print ''; print ''; - print "
'.$langs->trans("Search").'
'.$langs->trans("SearchThirdparty").'
"; print ':
"; print ':

"; +/* + * Search contact + */ +$rowspan=2; +if (! empty($conf->barcode->enabled)) $rowspan++; +print '
'; +print ''; +print ''; +print ''; +print ''; +print "'; +print ''; +print "'; +//print ''; +print ''; +print "
'.$langs->trans("SearchContact").'
"; +print ':
"; +print ':

"; /* * Statistics area @@ -121,7 +138,7 @@ print ''; print ''; 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 '"; + $statstring = ""; $statstring.= ''; $statstring.= ""; } if (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { - $statstring.= ""; + $statstring.= ""; $statstring.= ''; $statstring.= ""; } if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) { - $statstring2 = ""; + $statstring2 = ""; $statstring2.= ''; $statstring2.= ""; }
'.$langs->trans("Statistics").'
'; + print '
'; $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 = "
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'