Merge remote-tracking branch 'origin/3.4' into develop

Conflicts:
	ChangeLog
	htdocs/comm/propal.php
	htdocs/commande/fiche.php
	htdocs/compta/facture.php
	htdocs/fichinter/class/fichinter.class.php
	htdocs/fichinter/fiche.php
This commit is contained in:
Laurent Destailleur 2013-05-20 21:21:03 +02:00
commit 12681994ea
24 changed files with 1132 additions and 1052 deletions

View File

@ -69,6 +69,7 @@ For users:
- New: [ task #741 ] Add intervention box. - New: [ task #741 ] Add intervention box.
- New: [ task #826 ] Optionnal increase stock when deleting an invoice already validated. - New: [ task #826 ] Optionnal increase stock when deleting an invoice already validated.
- New: [ task #823 ] Shipping_validate email notification. - New: [ task #823 ] Shipping_validate email notification.
- New: [ task #900 ] Review code of ficheinter.class.php
For translators: For translators:
- Update language files. - Update language files.
@ -112,6 +113,7 @@ WARNING: If you used external modules, some of them may need to be upgraded due
- Fix: Can't reset payment due date - Fix: Can't reset payment due date
- Fix: Orderstoinvoice didn't act as expected when no order was checked - Fix: Orderstoinvoice didn't act as expected when no order was checked
- Fix: Bad link to all proposals into Third party card if customer is prospect - Fix: Bad link to all proposals into Third party card if customer is prospect
- Fix: Some bugs on withdrawal rejects
- Fix: [ bug #774 ] Bug on creating event with box "all day" crossed - Fix: [ bug #774 ] Bug on creating event with box "all day" crossed
- Fix: [ bug #787 ] Invoice supplier box incorrect tooltip when delay on payment - Fix: [ bug #787 ] Invoice supplier box incorrect tooltip when delay on payment
- Fix: [ bug #789 ] VAT not being calculated in POS - Fix: [ bug #789 ] VAT not being calculated in POS
@ -131,7 +133,7 @@ WARNING: If you used external modules, some of them may need to be upgraded due
- Fix: [ bug #865 ] Dolibarr navigation array in project/task do not work - Fix: [ bug #865 ] Dolibarr navigation array in project/task do not work
- Fix: [ bug #866 ] Standing order from an invoice suggests invoice total amount instead of remaining to pay - Fix: [ bug #866 ] Standing order from an invoice suggests invoice total amount instead of remaining to pay
- Fix: [ bug #788 ] Date of linked interventions are not shown - Fix: [ bug #788 ] Date of linked interventions are not shown
- Fix: external users should not see costprice and margin infos
***** ChangeLog for 3.3.1 compared to 3.3 ***** ***** ChangeLog for 3.3.1 compared to 3.3 *****

View File

@ -455,7 +455,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_SUPPLIER_ORDER_FREE_TEXT">'; print '<input type="hidden" name="action" value="set_SUPPLIER_ORDER_FREE_TEXT">';
print '<tr '.$bc[$var].'><td colspan="2">'; print '<tr '.$bc[$var].'><td colspan="2">';
print $langs->trans("FreeLegalTextOnInvoices").' ('.$langs->trans("AddCRIfTooLong").')<br>'; print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')<br>';
print '<textarea name="SUPPLIER_ORDER_FREE_TEXT" class="flat" cols="120">'.$conf->global->SUPPLIER_ORDER_FREE_TEXT.'</textarea>'; print '<textarea name="SUPPLIER_ORDER_FREE_TEXT" class="flat" cols="120">'.$conf->global->SUPPLIER_ORDER_FREE_TEXT.'</textarea>';
print '</td><td align="right">'; print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

View File

@ -638,6 +638,7 @@ else if ($action == "addline" && $user->rights->propal->creer)
$product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):'')));
$price_ht = GETPOST('price_ht'); $price_ht = GETPOST('price_ht');
$tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0); $tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0);
$predef=((! empty($idprod) && $conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : '');
if (empty($idprod) && GETPOST('type') < 0) if (empty($idprod) && GETPOST('type') < 0)
{ {
@ -1968,7 +1969,7 @@ else
// Show object lines // Show object lines
$result = $object->getLinesArray(); $result = $object->getLinesArray();
if (! empty($object->lines)) if (! empty($object->lines))
$ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1);
// Form to add new line // Form to add new line
if ($object->statut == 0 && $user->rights->propal->creer) if ($object->statut == 0 && $user->rights->propal->creer)

View File

@ -26,6 +26,7 @@
include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
/** /**
@ -49,14 +50,14 @@ class PropaleStats extends Stats
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param int $socid Id third party * @param int $socid Id third party
* @param int $userid Id user for filter * @param int $userid Id user for filter (creation user)
*/ */
function __construct($db, $socid=0, $userid=0) function __construct($db, $socid=0, $userid=0)
{ {
global $user, $conf; global $user, $conf;
$this->db = $db; $this->db = $db;
$this->socid = $socid; $this->socid = ($socid > 0 ? $socid : 0);
$this->userid = $userid; $this->userid = $userid;
$object=new Propal($this->db); $object=new Propal($this->db);
@ -66,7 +67,7 @@ class PropaleStats extends Stats
$this->field='total_ht'; $this->field='total_ht';
$this->where.= " fk_statut > 0"; $this->where.= " p.fk_statut > 0";
$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; $this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($this->socid) if($this->socid)
@ -90,7 +91,7 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(p.datep,'%m') as dm, count(*)"; $sql = "SELECT date_format(p.datep,'%m') as dm, count(*)";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -131,7 +132,7 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(p.datep,'%m') as dm, sum(p.".$this->field.")"; $sql = "SELECT date_format(p.datep,'%m') as dm, sum(p.".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -152,7 +153,7 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(p.datep,'%m') as dm, avg(p.".$this->field.")"; $sql = "SELECT date_format(p.datep,'%m') as dm, avg(p.".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(p.datep,'%Y') = '".$year."'"; $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');

View File

@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); $WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
$userid=GETPOST('userid','int'); if ($userid < 0) $userid=0; $userid=GETPOST('userid','int');
$socid=GETPOST('socid','int'); if ($socid < 0) $socid=0; $socid=GETPOST('socid','int');
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
@ -63,7 +63,7 @@ $dir=$conf->propal->dir_temp;
dol_mkdir($dir); dol_mkdir($dir);
$stats = new PropaleStats($db, $socid, $userid); $stats = new PropaleStats($db, $socid, ($userid>0?$userid:0));
// Build graphic number of object // Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
@ -233,12 +233,13 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print $form->select_company($socid,'socid',$filter,1); print $form->select_company($socid,'socid',$filter,1);
print '</td></tr>'; print '</td></tr>';
// User // User
print '<tr><td align="left">'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").'</td><td align="left">'; print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
print $form->select_users($userid,'userid',1); print $form->select_users($userid,'userid',1);
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">'; print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
arsort($arrayyears); arsort($arrayyears);
print $form->selectarray('year',$arrayyears,$year,0); print $form->selectarray('year',$arrayyears,$year,0);
print '</td></tr>'; print '</td></tr>';

View File

@ -26,6 +26,7 @@
include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
/** /**
@ -49,7 +50,7 @@ class CommandeStats extends Stats
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param int $socid Id third party for filter * @param int $socid Id third party for filter
* @param string $mode Option * @param string $mode Option
* @param int $userid Id user for filter * @param int $userid Id user for filter (creation user)
*/ */
function __construct($db, $socid, $mode, $userid=0) function __construct($db, $socid, $mode, $userid=0)
{ {
@ -57,7 +58,7 @@ class CommandeStats extends Stats
$this->db = $db; $this->db = $db;
$this->socid = $socid; $this->socid = ($socid > 0 ? $socid : 0);
$this->userid = $userid; $this->userid = $userid;
if ($mode == 'customer') if ($mode == 'customer')
@ -100,7 +101,7 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb"; $sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'"; $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -143,7 +144,7 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")"; $sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'"; $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -165,7 +166,7 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")"; $sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'"; $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');

View File

@ -36,8 +36,8 @@ $mode=GETPOST("mode")?GETPOST("mode"):'customer';
if ($mode == 'customer' && ! $user->rights->commande->lire) accessforbidden(); if ($mode == 'customer' && ! $user->rights->commande->lire) accessforbidden();
if ($mode == 'supplier' && ! $user->rights->fournisseur->commande->lire) accessforbidden(); if ($mode == 'supplier' && ! $user->rights->fournisseur->commande->lire) accessforbidden();
$userid=GETPOST('userid','int'); if ($userid < 0) $userid=0; $userid=GETPOST('userid','int');
$socid=GETPOST('socid','int'); if ($socid < 0) $socid=0; $socid=GETPOST('socid','int');
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
@ -77,7 +77,7 @@ print_fiche_titre($title);
dol_mkdir($dir); dol_mkdir($dir);
$stats = new CommandeStats($db, $socid, $mode, $userid); $stats = new CommandeStats($db, $socid, $mode, ($userid>0?$userid:0));
// Build graphic number of object // Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
@ -255,12 +255,13 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print $form->select_company($socid,'socid',$filter,1); print $form->select_company($socid,'socid',$filter,1);
print '</td></tr>'; print '</td></tr>';
// User // User
print '<tr><td align="left">'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").'</td><td align="left">'; print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
print $form->select_users($userid,'userid',1); print $form->select_users($userid,'userid',1);
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">'; print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
arsort($arrayyears); arsort($arrayyears);
print $form->selectarray('year',$arrayyears,$year,0); print $form->selectarray('year',$arrayyears,$year,0);
print '</td></tr>'; print '</td></tr>';

View File

@ -48,12 +48,12 @@ class FactureStats extends Stats
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param int $socid Id third party * @param int $socid Id third party
* @param string $mode Option * @param string $mode Option
* @param int $userid Id user for filter * @param int $userid Id user for filter (creation user)
* @return FactureStats * @return FactureStats
*/ */
function __construct($db, $socid, $mode, $userid=0) function __construct($db, $socid, $mode, $userid=0)
{ {
global $conf; global $user, $conf;
$this->db = $db; $this->db = $db;
$this->socid = ($socid > 0 ? $socid : 0); $this->socid = ($socid > 0 ? $socid : 0);
@ -62,41 +62,25 @@ class FactureStats extends Stats
if ($mode == 'customer') if ($mode == 'customer')
{ {
$object=new Facture($this->db); $object=new Facture($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element; $this->from = MAIN_DB_PREFIX.$object->table_element." as f";
$this->field='total'; $this->field='total';
} }
if ($mode == 'supplier') if ($mode == 'supplier')
{ {
$object=new FactureFournisseur($this->db); $object=new FactureFournisseur($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element; $this->from = MAIN_DB_PREFIX.$object->table_element." as f";
$this->field='total_ht'; $this->field='total_ht';
} }
$this->where = " fk_statut > 0"; $this->where = " f.fk_statut > 0";
$this->where.= " AND entity = ".$conf->entity; $this->where.= " AND f.entity = ".$conf->entity;
if ($mode == 'customer') $this->where.=" AND (fk_statut <> 3 OR close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($mode == 'customer') $this->where.=" AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons)
if ($this->socid) if ($this->socid)
{ {
$this->where.=" AND fk_soc = ".$this->socid; $this->where.=" AND f.fk_soc = ".$this->socid;
} }
if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid;
}
/**
* Renvoie le nombre de facture par annee
*
* @return array Array of values
*/
function getNbByYear()
{
$sql = "SELECT YEAR(datef) as dm, COUNT(*)";
$sql.= " FROM ".$this->from;
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC');
return $this->_getNbByYear($sql);
} }
@ -108,9 +92,10 @@ class FactureStats extends Stats
*/ */
function getNbByMonth($year) function getNbByMonth($year)
{ {
$sql = "SELECT MONTH(datef) as dm, COUNT(*)"; $sql = "SELECT MONTH(f.datef) as dm, COUNT(*)";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -121,6 +106,24 @@ class FactureStats extends Stats
} }
/**
* Renvoie le nombre de facture par annee
*
* @return array Array of values
*/
function getNbByYear()
{
$sql = "SELECT YEAR(f.datef) as dm, COUNT(*)";
$sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC');
return $this->_getNbByYear($sql);
}
/** /**
* Renvoie le montant de facture par mois pour une annee donnee * Renvoie le montant de facture par mois pour une annee donnee
* *
@ -129,9 +132,10 @@ class FactureStats extends Stats
*/ */
function getAmountByMonth($year) function getAmountByMonth($year)
{ {
$sql = "SELECT date_format(datef,'%m') as dm, SUM(".$this->field.")"; $sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE date_format(datef,'%Y') = '".$year."'"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -149,9 +153,10 @@ class FactureStats extends Stats
*/ */
function getAverageByMonth($year) function getAverageByMonth($year)
{ {
$sql = "SELECT date_format(datef,'%m') as dm, AVG(".$this->field.")"; $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -166,8 +171,9 @@ class FactureStats extends Stats
*/ */
function getAllByYear() function getAllByYear()
{ {
$sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where; $sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year"; $sql.= " GROUP BY year";
$sql.= $this->db->order('year','DESC'); $sql.= $this->db->order('year','DESC');

View File

@ -233,12 +233,13 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print $form->select_company($socid,'socid',$filter,1); print $form->select_company($socid,'socid',$filter,1);
print '</td></tr>'; print '</td></tr>';
// User // User
print '<tr><td>'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").'</td><td>'; print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>';
print $form->select_users($userid,'userid',1); print $form->select_users($userid,'userid',1);
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td>'.$langs->trans("Year").'</td><td>'; print '<tr><td>'.$langs->trans("Year").'</td><td>';
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
arsort($arrayyears); arsort($arrayyears);
print $form->selectarray('year',$arrayyears,$year,0); print $form->selectarray('year',$arrayyears,$year,0);
print '</td></tr>'; print '</td></tr>';

View File

@ -2712,7 +2712,7 @@ abstract class CommonObject
*/ */
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
{ {
global $conf,$langs,$hookmanager; global $conf,$langs,$user,$hookmanager;
print '<tr class="liste_titre nodrag nodrop">'; print '<tr class="liste_titre nodrag nodrop">';
@ -2735,7 +2735,8 @@ abstract class CommonObject
// Reduction short // Reduction short
print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>'; print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
if (! empty($conf->margin->enabled)) { if (! empty($conf->margin->enabled) && empty($user->societe_id))
{
if ($conf->global->MARGIN_TYPE == "1") if ($conf->global->MARGIN_TYPE == "1")
print '<td align="right" width="80">'.$langs->trans('BuyingPrice').'</td>'; print '<td align="right" width="80">'.$langs->trans('BuyingPrice').'</td>';
else else
@ -3159,11 +3160,16 @@ abstract class CommonObject
} }
/** /**
* displayMarginInfos
* *
* @param string $force_price * @param string $force_price Force price
* @return void
*/ */
function displayMarginInfos($force_price=false) { function displayMarginInfos($force_price=false)
global $langs, $conf; {
global $langs, $conf, $user;
if (! empty($user->societe_id)) return;
$marginInfo = $this->getMarginInfos($force_price); $marginInfo = $this->getMarginInfos($force_price);
@ -3215,6 +3221,5 @@ abstract class CommonObject
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
} }
} }
?> ?>

View File

@ -80,7 +80,7 @@ class modMargin extends DolibarrModules
// New pages on tabs // New pages on tabs
$this->tabs = array( $this->tabs = array(
'product:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/productMargins.php?id=__ID__', 'product:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/productMargins.php?id=__ID__',
'thirdparty:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/thirdpartyMargins.php?socid=__ID__' 'thirdparty:+margin:Margins:margins:$conf->margin->enabled && empty($user->societe_id):/margin/tabs/thirdpartyMargins.php?socid=__ID__'
); );

View File

@ -136,22 +136,19 @@ if ($forgetpasslink || $helpcenterlink)
if ($forgetpasslink) { if ($forgetpasslink) {
echo '<a class="alogin" href="'.DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam.'">('; echo '<a class="alogin" href="'.DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam.'">(';
echo $langs->trans('PasswordForgotten'); echo $langs->trans('PasswordForgotten');
if (! $helpcenterlink) { if (! $helpcenterlink) echo ')';
echo ')';
}
echo '</a>'; echo '</a>';
} }
if ($forgetpasslink && $helpcenterlink) echo '&nbsp;-&nbsp;';
if ($helpcenterlink) { if ($helpcenterlink) {
$url=DOL_URL_ROOT.'/support/index.php'.$moreparam; $url=DOL_URL_ROOT.'/support/index.php'.$moreparam;
if (! empty($conf->global->MAIN_HELPCENTER_LINKTOUSE)) $url=$conf->global->MAIN_HELPCENTER_LINKTOUSE; if (! empty($conf->global->MAIN_HELPCENTER_LINKTOUSE)) $url=$conf->global->MAIN_HELPCENTER_LINKTOUSE;
echo '<a class="alogin" href="'.dol_escape_htmltag($url).'" target="_blank">'; echo '<a class="alogin" href="'.dol_escape_htmltag($url).'" target="_blank">';
if ($forgetpasslink) { if (! $forgetpasslink) echo '(';
echo '&nbsp;-&nbsp;'; echo $langs->trans('NeedHelpCenter');
} else { echo ')</a>';
echo '(';
}
echo $langs->trans('NeedHelpCenter').')</a>';
} }
echo '</div>'; echo '</div>';
} }

View File

@ -119,7 +119,7 @@
<td>&nbsp;</td> <td>&nbsp;</td>
<?php } <?php }
if (! empty($conf->margin->enabled)) { if (! empty($conf->margin->enabled) && empty($user->societe_id)) {
?> ?>
<td align="right" class="nowrap"><?php echo price($line->pa_ht); ?></td> <td align="right" class="nowrap"><?php echo price($line->pa_ht); ?></td>
<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {?> <?php if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {?>

View File

@ -177,6 +177,7 @@ class Fichinter extends CommonObject
if (! $ret) dol_print_error($this->db); if (! $ret) dol_print_error($this->db);
} }
if (! $notrigger) if (! $notrigger)
{ {
// Appel des triggers // Appel des triggers
@ -737,6 +738,7 @@ class Fichinter extends CommonObject
} }
// Fin appel triggers // Fin appel triggers
} }
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }

View File

@ -137,6 +137,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
$object->socid = $socid; $object->socid = $socid;
$object->duree = GETPOST('duree','int'); $object->duree = GETPOST('duree','int');
$object->fk_project = GETPOST('projectid','int'); $object->fk_project = GETPOST('projectid','int');
$object->author = $user->id;
$object->description = GETPOST('description'); $object->description = GETPOST('description');
$object->ref = $ref; $object->ref = $ref;
$object->modelpdf = GETPOST('model','alpha'); $object->modelpdf = GETPOST('model','alpha');
@ -177,7 +178,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
$object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
} }
$id = $object->create($user); $id = $object->create();
if ($id > 0) if ($id > 0)
{ {
@ -646,8 +647,8 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
{ {
$langs->load('mails'); $langs->load('mails');
if ($object->fetch($id) > 0) { if ($object->fetch($id) > 0)
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if (GETPOST('sendto','alpha')) if (GETPOST('sendto','alpha'))
@ -1043,6 +1044,56 @@ if ($action == 'create')
} }
// Show link to origin object
if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
{
$newclassname=$classname;
if ($newclassname=='Propal') $newclassname='CommercialProposal';
print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
}
print '</table>';
if (is_object($objectsrc))
{
print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
}
// Model
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td colspan="2">';
$liste=ModelePDFFicheinter::liste_modeles($db);
print $form->selectarray('model',$liste,$conf->global->FICHEINTER_ADDON_PDF);
print "</td></tr>";
// Public note
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
//print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
print '</td></tr>';
// Private note
if (!empty($user->societe_id))
{
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
//print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
print '</td></tr>';
}
// Other attributes
$parameters=array('colspan' => ' colspan="2"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
// Show link to origin object // Show link to origin object
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
{ {

View File

@ -358,7 +358,7 @@ INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) V
-- Provinces Greece (id country=102) -- Provinces Greece (id country=102)
INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('66', 10201, NULL, NULL, NULL, 'Αθήνα', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('66', 10201, NULL, NULL, NULL, 'Αθήνα', 1);
INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('00', 10205, NULL, NULL, NULL, 'Δράμα', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('67', 10205, NULL, NULL, NULL, 'Δράμα', 1);
INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('01', 10205, NULL, NULL, NULL, 'Έβρος', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('01', 10205, NULL, NULL, NULL, 'Έβρος', 1);
INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('02', 10205, NULL, NULL, NULL, 'Θάσος', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('02', 10205, NULL, NULL, NULL, 'Θάσος', 1);
INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('03', 10205, NULL, NULL, NULL, 'Καβάλα', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('03', 10205, NULL, NULL, NULL, 'Καβάλα', 1);

View File

@ -101,6 +101,15 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 5
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 54, 5, '5.5','0','USt. Forst', 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 54, 5, '5.5','0','USt. Forst', 0);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 55, 5, '10.7','0','USt. Landwirtschaft', 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 55, 5, '10.7','0','USt. Landwirtschaft', 0);
-- GREECE (id country=102)
insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2462, 102, 23, 0, '0', 0, '0', 0, 'Κανονικός Φ.Π.Α.', 1);
insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2463, 102, 0, 0, '0', 0, '0', 0, 'Μηδενικό Φ.Π.Α.', 1);
insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2464, 102, 13, 0, '0', 0, '0', 0, 'Μειωμένος Φ.Π.Α.', 1);
insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2465, 102, 6.5, 0, '0', 0, '0', 0, 'Υπερμειωμένος Φ.Π.Α.', 1);
insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2466, 102, 16, 0, '0', 0, '0', 0, 'Νήσων κανονικός Φ.Π.Α.', 1);
insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2467, 102, 9, 0, '0', 0, '0', 0, 'Νήσων μειωμένος Φ.Π.Α.', 1);
insert into llx_c_tva(rowid,fk_pays,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (2468, 102, 5, 0, '0', 0, '0', 0, 'Νήσων υπερμειωμένος Φ.Π.Α.', 1);
-- ICELAND (id country=116) -- ICELAND (id country=116)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1161, 116,'25.5','0','VAT standard rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1161, 116,'25.5','0','VAT standard rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1162, 116, '7','0','VAT reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1162, 116, '7','0','VAT reduced rate',1);

View File

@ -393,6 +393,7 @@ AllCompletelyPayedInvoiceWillBeClosed=All invoice with no remain to pay will be
ToMakePayment=Pay ToMakePayment=Pay
ToMakePaymentBack=Pay back ToMakePaymentBack=Pay back
ListOfYourUnpaidInvoices=List of unpaid invoices ListOfYourUnpaidInvoices=List of unpaid invoices
NoteListOfYourUnpaidInvoices=Note: This list contains only invoices for third parties you are linked to as a sale representative.
RevenueStamp=Revenue stamp RevenueStamp=Revenue stamp
##### Types de contacts ##### ##### Types de contacts #####
TypeContact_facture_internal_SALESREPFOLL=Representative following-up customer invoice TypeContact_facture_internal_SALESREPFOLL=Representative following-up customer invoice

View File

@ -390,6 +390,7 @@ AllCompletelyPayedInvoiceWillBeClosed=Toutes les factures avec un reste à payer
ToMakePayment=Payer ToMakePayment=Payer
ToMakePaymentBack=Rembourser ToMakePaymentBack=Rembourser
ListOfYourUnpaidInvoices=Liste des factures impayées ListOfYourUnpaidInvoices=Liste des factures impayées
NoteListOfYourUnpaidInvoices=Remarque: Cette liste ne contient que les factures des Tiers pour lesquels vous êtes le commercial affecté.
RevenueStamp=Timbre fiscal RevenueStamp=Timbre fiscal
##### Types de contacts ##### ##### Types de contacts #####
TypeContact_facture_internal_SALESREPFOLL=Responsable suivi facture client TypeContact_facture_internal_SALESREPFOLL=Responsable suivi facture client

View File

@ -43,8 +43,8 @@ MargeBrute=Marge brute
MargeNette=Marge nette MargeNette=Marge nette
MARGIN_TYPE_DETAILS=Marge brute : Prix de vente HT - Prix d'achat HT<br/>Marge nette : Prix de vente HT - Coût de revient MARGIN_TYPE_DETAILS=Marge brute : Prix de vente HT - Prix d'achat HT<br/>Marge nette : Prix de vente HT - Coût de revient
CostPrice=Prix ​​d'achat BuyingPrice=Prix ​​d'achat
BuyingCost=Coût de revient CostPrice=Prix de revient
UnitCharges=Charge unitaire UnitCharges=Charge unitaire
Charges=Charges Charges=Charges

View File

@ -207,7 +207,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
else else
{ {
$allmessage.= $newlangs->transnoentities("ListOfYourUnpaidInvoices").($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n"); $allmessage.= $newlangs->transnoentities("ListOfYourUnpaidInvoices").($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
$allmessage.= "Note: This list contains only invoices for third parties you are linked to as a sale representative.".($usehtml?"<br>\n":"\n"); $allmessage.= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices").($usehtml?"<br>\n":"\n");
} }
$allmessage.= $message.($usehtml?"<br>\n":"\n"); $allmessage.= $message.($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total).($usehtml?"<br>\n":"\n"); $allmessage.= $langs->trans("Total")." = ".price($total).($usehtml?"<br>\n":"\n");