+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/admin/agenda.php
+ * \ingroup agenda
+ * \brief Autocreate actions for agenda module setup page
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
+
+if (!$user->admin)
+ accessforbidden();
+
+$langs->load("admin");
+$langs->load("other");
+
+$action = GETPOST('action','alpha');
+$cancel = GETPOST('cancel','alpha');
+
+
+/*
+ * Actions
+ */
+
+if (preg_match('/set_(.*)/',$action,$reg))
+{
+ $code=$reg[1];
+ $value=(GETPOST($code) ? GETPOST($code) : 1);
+ if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
+ {
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+}
+
+if (preg_match('/del_(.*)/',$action,$reg))
+{
+ $code=$reg[1];
+ if (dolibarr_del_const($db, $code, $conf->entity) > 0)
+ {
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+}
+
+
+/**
+ * View
+ */
+
+llxHeader();
+
+$linkback=''.$langs->trans("BackToModuleList").' ';
+print_fiche_titre($langs->trans("AgendaSetup"),$linkback,'setup');
+print " \n";
+
+
+$head=agenda_prepare_head();
+
+dol_fiche_head($head, 'other', $langs->trans("Agenda"));
+
+print_titre($langs->trans("OtherOptions"));
+
+$var=true;
+
+print ''."\n";
+print ''."\n";
+print ''.$langs->trans("Parameters").' '."\n";
+print ' '."\n";
+print ''.$langs->trans("Value").' '."\n";
+print ' '."\n";
+
+// Manual or automatic
+$var=!$var;
+print ''."\n";
+print ''.$langs->trans("AGENDA_USE_EVENT_TYPE").' '."\n";
+print ' '."\n";
+
+print ''."\n";
+if ($conf->use_javascript_ajax)
+{
+ print ajax_constantonoff('AGENDA_USE_EVENT_TYPE');
+}
+else
+{
+ if($conf->global->AGENDA_USE_EVENT_TYPE == 0)
+ {
+ print ''.img_picto($langs->trans("Disabled"),'off').' ';
+ }
+ else if($conf->global->BUSINESS_VISIBLE_TO_ALL_BY_DEFAULT == 1)
+ {
+ print ''.img_picto($langs->trans("Enabled"),'on').' ';
+ }
+}
+print ' '."\n";
+
+print '
';
+
+dol_fiche_end();
+
+print " ";
+
+dol_htmloutput_mesg($mesg);
+
+llxFooter();
+
+$db->close();
+?>
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 6405e8ac8a8..41178e36012 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -391,7 +391,7 @@ if ($id == 11)
// Define localtax_typeList (used for dictionnary "c_tva")
$localtax_typeList = array();
-if (GETPOST("id") == 10)
+if ($id == 10)
{
$localtax_typeList = array(
"0" => $langs->trans("No"),
@@ -441,22 +441,32 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
if ($fieldnamekey == 'unicode') $fieldnamekey = 'Unicode';
- $msg.=$langs->trans("ErrorFieldRequired",$langs->transnoentities($fieldnamekey)).' ';
+ $msg.=$langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)).' ';
}
}
// Other checks
if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"],array('system','systemauto'))) {
$ok=0;
- $msg.="Value 'system' and 'systemauto' for type is reserved. You can use 'user' as value to add your own record. ";
+ $msg.= $langs->transnoentities('ErrorReservedTypeSystemSystemAuto').' ';
}
- if (isset($_POST["code"]) && $_POST["code"]=='0') {
- $ok=0;
- $msg.="Code can't contains value 0 ";
+ if (isset($_POST["code"]))
+ {
+ if ($_POST["code"]=='0')
+ {
+ $ok=0;
+ $msg.= $langs->transnoentities('ErrorCodeCantContainZero').' ';
+ }
+ if (!is_numeric($_POST['code']))
+ {
+ $ok = 0;
+ $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).' ';
+ }
}
if (isset($_POST["country"]) && $_POST["country"]=='0') {
$ok=0;
- $msg.=$langs->trans("ErrorFieldRequired",$langs->trans("Country")).' ';
+ $msg.=$langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")).' ';
}
+
// Clean some parameters
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0
@@ -518,7 +528,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
- $msg=$langs->trans("ErrorRecordAlreadyExists").' ';
+ $msg=$langs->transnoentities("ErrorRecordAlreadyExists").' ';
}
else {
dol_print_error($db);
@@ -588,7 +598,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
- $msg=''.$langs->trans("ErrorRecordIsUsedByChild").'
';
+ $msg=''.$langs->transnoentities("ErrorRecordIsUsedByChild").'
';
}
else
{
@@ -994,6 +1004,7 @@ if ($id)
$valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') {
+ $langs->load('agenda');
$key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index 569200f35e4..f7bd7ad95d7 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
$langs->load("admin");
+$langs->load('other');
if (! $user->admin) accessforbidden();
diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php
index ddc7079c786..ec2a2b49d63 100644
--- a/htdocs/categories/categorie.php
+++ b/htdocs/categories/categorie.php
@@ -99,7 +99,7 @@ $error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->e
if (empty($reshook))
{
- //Suppression d'un objet d'une categorie
+ // Remove element from category
if ($removecat > 0)
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
@@ -113,17 +113,20 @@ if (empty($reshook))
{
$object = new Societe($db);
$result = $object->fetch($objectid);
+ $elementtype = 'fournisseur';
}
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
+ $elementtype = 'societe';
}
if ($type == 3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
+ $elementtype = 'member';
}
$cat = new Categorie($db);
$result=$cat->fetch($removecat);
@@ -507,7 +510,7 @@ function formCategory($db,$object,$typeid,$socid=0)
//print $c->getNomUrl(1);
print img_object('','category').' '.$way."";
- // Lien supprimer
+ // Link to delete from category
print '';
$permission=0;
if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 96c111f2dc0..377c06fd8d8 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -420,6 +420,7 @@ class Categorie
$sql .= " WHERE fk_categorie = ".$this->id;
$sql .= " AND fk_".($type=='fournisseur'?'societe':$type)." = ".$obj->id;
+ dol_syslog(get_class($this).'::del_type sql='.$sql);
if ($this->db->query($sql))
{
return 1;
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index f174f5f4a60..57cffd387de 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -36,6 +36,7 @@ $ref=GETPOST('ref');
$type=GETPOST('type');
$action=GETPOST('action');
$confirm=GETPOST('confirm');
+$removeelem = GETPOST('removeelem','int');
if ($id == "")
{
@@ -61,6 +62,40 @@ $type=$object->type;
* Actions
*/
+// Remove element from category
+if ($id > 0 && $removeelem > 0)
+{
+ if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
+ {
+ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+ $tmpobject = new Product($db);
+ $result = $tmpobject->fetch($removeelem);
+ $elementtype = 'product';
+ }
+ if ($type==1 && $user->rights->societe->creer)
+ {
+ $tmpobject = new Societe($db);
+ $result = $tmpobject->fetch($removeelem);
+ $elementtype = 'fournisseur';
+ }
+ if ($type==2 && $user->rights->societe->creer)
+ {
+ $tmpobject = new Societe($db);
+ $result = $tmpobject->fetch($removeelem);
+ $elementtype = 'societe';
+ }
+ if ($type == 3 && $user->rights->adherent->creer)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
+ $tmpobject = new Adherent($db);
+ $result = $tmpobject->fetch($removeelem);
+ $elementtype = 'member';
+ }
+
+ $result=$object->del_type($tmpobject,$elementtype);
+ if ($result < 0) dol_print_error('',$object->error);
+}
+
if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
{
if ($object->delete($user) >= 0)
@@ -214,7 +249,7 @@ if ($object->type == 0)
{
print " ";
print "\n";
- print ''.$langs->trans("ProductsAndServices")." \n";
+ print ''.$langs->trans("ProductsAndServices")." \n";
if (count($prods) > 0)
{
@@ -224,10 +259,24 @@ if ($object->type == 0)
$var=!$var;
print "\t\n";
print '';
- if ($prod->type == 1) print img_object($langs->trans("ShowService"),"service");
- else print img_object($langs->trans("ShowProduct"),"product");
- print " ".$prod->ref." \n";
+ print $prod->getNomUrl(1,'category');
+ print "\n";
print ''.$prod->libelle." \n";
+ // Link to delete from category
+ print '';
+ $typeid=$object->type;
+ $permission=0;
+ if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
+ if ($typeid == 1) $permission=$user->rights->societe->creer;
+ if ($typeid == 2) $permission=$user->rights->societe->creer;
+ if ($typeid == 3) $permission=$user->rights->adherent->creer;
+ if ($permission)
+ {
+ print "id."&type=".$typeid."&removeelem=".$prod->id."'>";
+ print img_delete($langs->trans("DeleteFromCat")).' ';
+ print $langs->trans("DeleteFromCat")." ";
+ }
+ print ' ';
print " \n";
}
}
@@ -249,8 +298,8 @@ if ($object->type == 1)
else
{
print " ";
- print "\n";
- print "".$langs->trans("Suppliers")." \n";
+ print ''."\n";
+ print ''.$langs->trans("Suppliers")." \n";
if (count($socs) > 0)
{
@@ -261,9 +310,24 @@ if ($object->type == 1)
print "\t\n";
print '';
- print $soc->getNomUrl(1);
+ print $soc->getNomUrl(1,'category_supplier');
print " \n";
-
+ // Link to delete from category
+ print '';
+ $typeid=$object->type;
+ $permission=0;
+ if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
+ if ($typeid == 1) $permission=$user->rights->societe->creer;
+ if ($typeid == 2) $permission=$user->rights->societe->creer;
+ if ($typeid == 3) $permission=$user->rights->adherent->creer;
+ if ($permission)
+ {
+ print "id."&type=".$typeid."&removeelem=".$soc->id."'>";
+ print img_delete($langs->trans("DeleteFromCat")).' ';
+ print $langs->trans("DeleteFromCat")." ";
+ }
+ print ' ';
+
print " \n";
}
}
@@ -285,8 +349,8 @@ if($object->type == 2)
else
{
print " ";
- print "\n";
- print "".$langs->trans("Customers")." \n";
+ print ''."\n";
+ print ''.$langs->trans("Customers")." \n";
if (count($socs) > 0)
{
@@ -298,9 +362,23 @@ if($object->type == 2)
$var=!$var;
print "\t\n";
print '';
- print $soc->getNomUrl(1);
+ print $soc->getNomUrl(1,'category');
print " \n";
-
+ // Link to delete from category
+ print '';
+ $typeid=$object->type;
+ $permission=0;
+ if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
+ if ($typeid == 1) $permission=$user->rights->societe->creer;
+ if ($typeid == 2) $permission=$user->rights->societe->creer;
+ if ($typeid == 3) $permission=$user->rights->adherent->creer;
+ if ($permission)
+ {
+ print "id."&type=".$typeid."&removeelem=".$soc->id."'>";
+ print img_delete($langs->trans("DeleteFromCat")).' ';
+ print $langs->trans("DeleteFromCat")." ";
+ }
+ print ' ';
print " \n";
}
}
@@ -326,7 +404,7 @@ if ($object->type == 3)
{
print " ";
print "\n";
- print ''.$langs->trans("Member")." \n";
+ print ''.$langs->trans("Member")." \n";
if (count($prods) > 0)
{
@@ -336,10 +414,25 @@ if ($object->type == 3)
$var=!$var;
print "\t\n";
print '';
- print $member->getNomUrl(1);
+ $member->ref=$member->login;
+ print $member->getNomUrl(1,0,'category');
print " \n";
print ''.$member->lastname." \n";
print ''.$member->firstname." \n";
+ // Link to delete from category
+ print '';
+ $typeid=$object->type;
+ $permission=0;
+ if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
+ if ($typeid == 1) $permission=$user->rights->societe->creer;
+ if ($typeid == 2) $permission=$user->rights->societe->creer;
+ if ($typeid == 3) $permission=$user->rights->adherent->creer;
+ if ($permission)
+ {
+ print "id."&type=".$typeid."&removeelem=".$member->id."'>";
+ print img_delete($langs->trans("DeleteFromCat")).' ';
+ print $langs->trans("DeleteFromCat")." ";
+ }
print " \n";
}
}
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index b6357880dad..4b4917715b5 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2012 Laurent Destailleur
+ * Copyright (C) 2004-2013 Laurent Destailleur
* Copyright (C) 2005 Simon TOSSER
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2010 Juanjo Menent
@@ -663,7 +663,6 @@ if ($id > 0)
*/
$head=actions_prepare_head($act);
- dol_fiche_head($head, 'card', $langs->trans("Action"),0,'action');
$now=dol_now();
$delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;
@@ -711,6 +710,8 @@ if ($id > 0)
print ' ';
if ($backtopage) print ' ';
+ dol_fiche_head($head, 'card', $langs->trans("Action"),0,'action');
+
print '';
// Ref
@@ -836,7 +837,9 @@ if ($id > 0)
print '
';
- print ' ';
+ dol_fiche_end();
+
+ print ' ';
print ' ';
print ' ';
@@ -844,6 +847,8 @@ if ($id > 0)
}
else
{
+ dol_fiche_head($head, 'card', $langs->trans("Action"),0,'action');
+
// Affichage fiche action en mode visu
print '';
@@ -1021,14 +1026,13 @@ if ($id > 0)
}
print '
';
}
- }
- print "\n";
+ dol_fiche_end();
+ }
/*
* Barre d'actions
- *
*/
print '';
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index c178c37078b..2a7c92dce56 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1534,7 +1534,7 @@ else
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$notify=new Notify($db);
$text.=' ';
- $text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$object->socid);
+ $text.=$notify->confirmMessage('PROPAL_VALIDATE',$object->socid);
}
if (! $error) $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1);
@@ -2171,7 +2171,7 @@ else
//print '
';
- print '';
+ print '';
}
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 9cc8da95d51..4801305a091 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1784,7 +1784,7 @@ else
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$notify=new Notify($db);
$text.=' ';
- $text.=$notify->confirmMessage('NOTIFY_VAL_ORDER',$object->socid);
+ $text.=$notify->confirmMessage('ORDER_VALIDATE',$object->socid);
}
$formquestion=array();
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1))
@@ -1935,15 +1935,15 @@ else
print ''.$soc->getNomUrl(1).' ';
print '';
- if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
- {
- $filterabsolutediscount="fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
- $filtercreditnote="fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
- }
- else
- {
- $filterabsolutediscount="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')";
- $filtercreditnote="fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
+ {
+ $filterabsolutediscount="fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ $filtercreditnote="fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ }
+ else
+ {
+ $filterabsolutediscount="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')";
+ $filtercreditnote="fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
}
// Relative and absolute discounts
@@ -2170,9 +2170,9 @@ else
}
}
- $rowspan=4;
- if ($mysoc->localtax1_assuj=="1") $rowspan++;
- if ($mysoc->localtax2_assuj=="1") $rowspan++;
+ $rowspan=4;
+ if ($mysoc->localtax1_assuj=="1") $rowspan++;
+ if ($mysoc->localtax2_assuj=="1") $rowspan++;
// Total HT
print ''.$langs->trans('AmountHT').' ';
@@ -2411,7 +2411,7 @@ else
print '';
}
}
- print ' ';
+ print ' ';
if ($action != 'presend')
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 2a02522bbcc..6c190bac20b 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -2523,7 +2523,7 @@ else if ($id > 0 || ! empty($ref))
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$notify=new Notify($db);
$text.=' ';
- $text.=$notify->confirmMessage('NOTIFY_VAL_FAC',$object->socid);
+ $text.=$notify->confirmMessage('BILL_VALIDATE',$object->socid);
}
$formquestion=array();
@@ -3618,7 +3618,7 @@ else if ($id > 0 || ! empty($ref))
print '';
}
}
- print ' ';
+ print ' ';
if ($action != 'prerelance' && $action != 'presend')
{
@@ -3659,7 +3659,7 @@ else if ($id > 0 || ! empty($ref))
$somethingshown=$formactions->showactions($object,'invoice',$socid);
//print '
';
- print '';
+ print '';
}
else
{
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 58e57d7f88c..a2a9cf6da13 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -3528,31 +3528,31 @@ class FactureLigne
$this->db->begin();
- // Mise a jour ligne en base
- $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
- $sql.= " description='".$this->db->escape($this->desc)."'";
- $sql.= ",label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null");
- $sql.= ",subprice=".price2num($this->subprice)."";
- $sql.= ",remise_percent=".price2num($this->remise_percent)."";
- if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
- else $sql.= ",fk_remise_except=null";
- $sql.= ",tva_tx=".price2num($this->tva_tx)."";
- $sql.= ",localtax1_tx=".price2num($this->localtax1_tx)."";
- $sql.= ",localtax2_tx=".price2num($this->localtax2_tx)."";
- $sql.= ",qty=".price2num($this->qty)."";
- $sql.= ",date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
- $sql.= ",date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
- $sql.= ",product_type=".$this->product_type;
- $sql.= ",info_bits='".$this->info_bits."'";
- $sql.= ",special_code='".$this->special_code."'";
- if (empty($this->skip_update_total))
- {
- $sql.= ",total_ht=".price2num($this->total_ht)."";
- $sql.= ",total_tva=".price2num($this->total_tva)."";
- $sql.= ",total_ttc=".price2num($this->total_ttc)."";
- $sql.= ",total_localtax1=".price2num($this->total_localtax1)."";
- $sql.= ",total_localtax2=".price2num($this->total_localtax2)."";
- }
+ // Mise a jour ligne en base
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
+ $sql.= " description='".$this->db->escape($this->desc)."'";
+ $sql.= ",label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null");
+ $sql.= ",subprice=".price2num($this->subprice)."";
+ $sql.= ",remise_percent=".price2num($this->remise_percent)."";
+ if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
+ else $sql.= ",fk_remise_except=null";
+ $sql.= ",tva_tx=".price2num($this->tva_tx)."";
+ $sql.= ",localtax1_tx=".price2num($this->localtax1_tx)."";
+ $sql.= ",localtax2_tx=".price2num($this->localtax2_tx)."";
+ $sql.= ",qty=".price2num($this->qty)."";
+ $sql.= ",date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
+ $sql.= ",date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
+ $sql.= ",product_type=".$this->product_type;
+ $sql.= ",info_bits='".$this->info_bits."'";
+ $sql.= ",special_code='".$this->special_code."'";
+ if (empty($this->skip_update_total))
+ {
+ $sql.= ",total_ht=".price2num($this->total_ht)."";
+ $sql.= ",total_tva=".price2num($this->total_tva)."";
+ $sql.= ",total_ttc=".price2num($this->total_ttc)."";
+ $sql.= ",total_localtax1=".price2num($this->total_localtax1)."";
+ $sql.= ",total_localtax2=".price2num($this->total_localtax2)."";
+ }
$sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null");
$sql.= " , buy_price_ht='".price2num($this->pa_ht)."'";
$sql.= ",fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php
new file mode 100644
index 00000000000..6adbd4ebf06
--- /dev/null
+++ b/htdocs/compta/stats/cabyprodserv.php
@@ -0,0 +1,390 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/compta/stats/cabyprodserv.php
+ * \brief Page reporting TO by Products & Services
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+
+$langs->load("products");
+$langs->load("categories");
+$langs->load("errors");
+
+// Security pack (data & check)
+$socid = GETPOST('socid','int');
+
+if ($user->societe_id > 0) $socid = $user->societe_id;
+if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat');
+if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport');
+
+// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
+$modecompta = $conf->global->COMPTA_MODE;
+if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta");
+
+$sortorder=isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
+$sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
+if (! $sortorder) $sortorder="asc";
+if (! $sortfield) $sortfield="name";
+
+// Category
+$selected_cat = (int)GETPOST('search_categ', 'int');
+$subcat = false;
+if (GETPOST('subcat', 'alpha') === 'yes') {
+ $subcat = true;
+}
+
+// Date range
+$year=GETPOST("year");
+$month=GETPOST("month");
+$date_startyear = GETPOST("date_startyear");
+$date_startmonth = GETPOST("date_startmonth");
+$date_startday = GETPOST("date_startday");
+$date_endyear = GETPOST("date_endyear");
+$date_endmonth = GETPOST("date_endmonth");
+$date_endday = GETPOST("date_endday");
+if (empty($year))
+{
+ $year_current = strftime("%Y",dol_now());
+ $month_current = strftime("%m",dol_now());
+ $year_start = $year_current;
+} else {
+ $year_current = $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_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
+// Quarter
+if (empty($date_start) || empty($date_end)) // We define date_start and date_end
+{
+ $q=GETPOST("q")?GETPOST("q"):0;
+ if ($q==0)
+ {
+ // We define date_start and date_end
+ $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
+ $year_end=$year_start;
+ $month_end=$month_start;
+ if (! GETPOST("month")) // If month not forced
+ {
+ if (! GETPOST('year') && $month_start > $month_current)
+ {
+ $year_start--;
+ $year_end--;
+ }
+ $month_end=$month_start-1;
+ if ($month_end < 1) $month_end=12;
+ else $year_end++;
+ }
+ $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false);
+ }
+ if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
+ if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }
+ if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); }
+ if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
+} else {
+ // TODO We define q
+}
+
+$commonparams=array();
+$commonparams['modecompta']=$modecompta;
+$commonparams['sortorder'] = $sortorder;
+$commonparams['sortfield'] = $sortfield;
+
+$headerparams = array();
+$headerparams['date_startyear'] = $date_startyear;
+$headerparams['date_startmonth'] = $date_startmonth;
+$headerparams['date_startday'] = $date_startday;
+$headerparams['date_endyear'] = $date_endyear;
+$headerparams['date_endmonth'] = $date_endmonth;
+$headerparams['date_endday'] = $date_endday;
+$headerparams['q'] = $q;
+
+$tableparams = array();
+$tableparams['search_categ'] = $selected_cat;
+$tableparams['subcat'] = ($subcat === true)?'yes':'';
+
+// Adding common parameters
+$allparams = array_merge($commonparams, $headerparams, $tableparams);
+$headerparams = array_merge($commonparams, $headerparams);
+$tableparams = array_merge($commonparams, $tableparams);
+
+foreach($allparams as $key => $value) {
+ $paramslink .= '&' . $key . '=' . $value;
+}
+/*
+ * View
+ */
+llxHeader();
+$form=new Form($db);
+$formother = new FormOther($db);
+
+// Show report header
+$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByProductsAndServices");
+
+if ($modecompta=="CREANCES-DETTES") {
+ $nom.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
+
+ $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);
+
+ $description=$langs->trans("RulesCADue");
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ $description.= $langs->trans("DepositsAreNotIncluded");
+ } else {
+ $description.= $langs->trans("DepositsAreIncluded");
+ }
+
+ $builddate=time();
+} else {
+ $nom.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
+
+ $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);
+
+ $description=$langs->trans("RulesCAIn");
+ $description.= $langs->trans("DepositsAreIncluded");
+
+ $builddate=time();
+}
+
+report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams);
+
+
+// SQL request
+$catotal=0;
+
+if ($modecompta == 'CREANCES-DETTES') {
+ $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label,";
+ $sql.= " sum(DISTINCT l.total_ht) as amount, sum(DISTINCT l.total_ttc) as amount_ttc";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
+ $sql.= " JOIN ".MAIN_DB_PREFIX."facturedet as l";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON l.fk_facture = f.rowid";
+ if ($selected_cat === -2) {
+ $sql.=" LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
+ }
+ if ($selected_cat && $selected_cat !== -2) {
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = " . $selected_cat;
+ if ($subcat) {
+ $sql.=" OR c.fk_parent = " . $selected_cat;
+ }
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_categorie = c.rowid";
+ }
+ $sql.= " WHERE l.fk_product = p.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 ($selected_cat === -2) {
+ $sql.=" AND cp.fk_product is null";
+ }
+ if ($selected_cat && $selected_cat !== -2) {
+ $sql.= " AND cp.fk_product = p.rowid";
+ }
+ $sql.= " AND f.entity = ".$conf->entity;
+ $sql.= " GROUP BY p.rowid ";
+ $sql.= "ORDER BY p.ref ";
+
+ $result = $db->query($sql);
+ if ($result) {
+ $num = $db->num_rows($result);
+ $i=0;
+ while ($i < $num) {
+ $obj = $db->fetch_object($result);
+ $amount_ht[$obj->rowid] = $obj->amount;
+ $amount[$obj->rowid] = $obj->amount_ttc;
+ $name[$obj->rowid] = $obj->ref . ' - ' . $obj->label;
+ $catotal_ht+=$obj->amount;
+ $catotal+=$obj->amount_ttc;
+ $i++;
+ }
+ } else {
+ dol_print_error($db);
+ }
+
+ // Show Array
+ $i=0;
+ print '';
+} else {
+ // $modecompta != 'CREANCES-DETTES'
+ // TODO: better message
+ print '' . $langs->trans("WarningNotRelevant") . '
';
+}
+
+llxFooter();
+$db->close();
+?>
diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php
index 86f16cf3684..82bbff465eb 100644
--- a/htdocs/compta/stats/cabyuser.php
+++ b/htdocs/compta/stats/cabyuser.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2001-2003 Rodolphe Quiedeville
* Copyright (C) 2004-2011 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2013 Antoine Iauch
*
* 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
@@ -46,6 +47,12 @@ if (! $sortfield) $sortfield="name";
// Date range
$year=GETPOST("year");
$month=GETPOST("month");
+$date_startyear = GETPOST("date_startyear");
+$date_startmonth = GETPOST("date_startmonth");
+$date_startday = GETPOST("date_startday");
+$date_endyear = GETPOST("date_endyear");
+$date_endmonth = GETPOST("date_endmonth");
+$date_endday = GETPOST("date_endday");
if (empty($year))
{
$year_current = strftime("%Y",dol_now());
@@ -89,9 +96,34 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
else
{
// TODO We define q
-
}
+$commonparams=array();
+$commonparams['modecompta']=$modecompta;
+$commonparams['sortorder'] = $sortorder;
+$commonparams['sortfield'] = $sortfield;
+
+$headerparams = array();
+$headerparams['date_startyear'] = $date_startyear;
+$headerparams['date_startmonth'] = $date_startmonth;
+$headerparams['date_startday'] = $date_startday;
+$headerparams['date_endyear'] = $date_endyear;
+$headerparams['date_endmonth'] = $date_endmonth;
+$headerparams['date_endday'] = $date_endday;
+$headerparams['q'] = $q;
+
+$tableparams = array();
+$tableparams['search_categ'] = $selected_cat;
+$tableparams['subcat'] = ($subcat === true)?'yes':'';
+
+// Adding common parameters
+$allparams = array_merge($commonparams, $headerparams, $tableparams);
+$headerparams = array_merge($commonparams, $headerparams);
+$tableparams = array_merge($commonparams, $tableparams);
+
+foreach($allparams as $key => $value) {
+ $paramslink .= '&' . $key . '=' . $value;
+}
/*
* View
@@ -102,9 +134,8 @@ llxHeader();
$form=new Form($db);
-// Affiche en-tete du rapport
-if ($modecompta=="CREANCES-DETTES")
-{
+// Show report header
+if ($modecompta=="CREANCES-DETTES") {
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice");
$nom.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
$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);
@@ -114,8 +145,7 @@ if ($modecompta=="CREANCES-DETTES")
else $description.= $langs->trans("DepositsAreIncluded");
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
-}
-else {
+} else {
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice");
$nom.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
$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);
@@ -131,20 +161,29 @@ if (! empty($modecompta)) $moreparam['modecompta']=$modecompta;
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam);
-// Charge tableau
-$catotal=0;
-if ($modecompta == 'CREANCES-DETTES')
+// Show array
+print '