Sun, 21 March 2015 12:00:00 +0100
diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php
index ff0c2f61200..1f5b56e661b 100644
--- a/dev/skeletons/skeleton_class.class.php
+++ b/dev/skeletons/skeleton_class.class.php
@@ -270,28 +270,20 @@ class Skeleton_Class extends CommonObject
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
- if (! $error)
+ if (! $error && ! $notrigger)
{
- if (! $notrigger)
- {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
- //// Call triggers
- //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
- //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
- //// End call triggers
- }
+ //// Call triggers
+ //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
+ //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ //// End call triggers
}
// Commit or rollback
if ($error)
{
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
$this->db->rollback();
return -1*$error;
}
@@ -344,11 +336,6 @@ class Skeleton_Class extends CommonObject
// Commit or rollback
if ($error)
{
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
$this->db->rollback();
return -1*$error;
}
diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php
new file mode 100644
index 00000000000..b1ccca39dee
--- /dev/null
+++ b/dev/translation/sanity_check_en_langfiles.php
@@ -0,0 +1,222 @@
+
+*
+* 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 2 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 .
+*/
+
+echo "";
+echo "";
+
+echo "";
+
+echo "";
+echo "If you call this file with the argument \"?unused=true\" it searches for the translation strings that exist in en_US but are never used ";
+echo "IMPORTANT: that can take quite a lot of time (up to 10 minutes), you need to tune the max_execution_time on your php.ini accordingly ";
+echo "Happy translating :) ";
+
+// directory containing the php and lang files
+$htdocs = "../../htdocs/";
+// directory containing the english lang files
+$workdir = $htdocs."langs/en_US/";
+
+$files = scandir($workdir);
+$exludefiles = array('.','..','README');
+$files = array_diff($files,$exludefiles);
+$langstrings_3d = array();
+$langstrings_full = array();
+foreach ($files AS $file) {
+ $path_file = pathinfo($file);
+ // we're only interested in .lang files
+ if ($path_file['extension']=='lang') {
+ $content = file($workdir.$file);
+ foreach ($content AS $line => $row) {
+ // don't want comment lines
+ if (substr($row,0,1) !== '#') {
+ // don't want lines without the separator (why should those even be here, anyway...)
+ if (strpos($row,'=')!==false) {
+ $row_array = explode('=',$row);
+ $langstrings_3d[$path_file['basename']][$line+1]=$row_array[0];
+ $langstrings_full[]=$row_array[0];
+ $langstrings_dist[$row_array[0]]=$row_array[0];
+ }
+ }
+ }
+ }
+}
+
+foreach ($langstrings_3d AS $filename => $file) {
+ foreach ($file AS $linenum => $value) {
+ $keys = array_keys($langstrings_full, $value);
+ if (count($keys)>1) {
+ foreach ($keys AS $key) {
+ $dups[$value][$filename][$linenum] = '';
+ }
+ }
+ }
+}
+
+echo "Duplicate strings in lang files in $workdir - ".count($dups)." found ";
+echo "";
+
+echo " ";
+echo "# String File and lines ";
+echo "";
+$count = 0;
+foreach ($dups as $string => $pages) {
+ $count++;
+ echo "";
+ echo "$count ";
+ echo "$string ";
+ echo "";
+ foreach ($pages AS $page => $lines ) {
+ echo "$page ";
+ foreach ($lines as $line => $nothing) {
+ echo "($line) ";
+ }
+ echo " ";
+ }
+ echo " ";
+}
+echo " ";
+echo "
";
+
+
+if ($_REQUEST['unused'] == 'true') {
+
+ foreach ($langstrings_dist AS $value){
+ $search = '\'trans("'.$value.'")\'';
+ $string = 'grep -R -m 1 -F --include=*.php '.$search.' '.$htdocs.'*';
+ exec($string,$output);
+ if (empty($output)) {
+ $unused[$value] = true;
+ echo $value.' ';
+ }
+ }
+
+ echo "Strings in en_US that are never used ";
+ echo "";
+ print_r($unused);
+}
+echo "";
+echo "";
+?>
\ No newline at end of file
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 7605d54825c..c2c51bacd42 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -178,7 +178,7 @@ if ($result) {
/*
* Action
- * FIXME Action must be set before any view part
+ * FIXME Action must be set before any view part to respect MVC
*/
// Bookkeeping Write
diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/public.php
index 0f92e017437..19fce918a31 100644
--- a/htdocs/adherents/admin/public.php
+++ b/htdocs/adherents/admin/public.php
@@ -164,7 +164,7 @@ print ' ';
print '';
print $langs->trans("DefaultAmount");
print ' ';
-print ' ';;
+print ' ';
print " \n";
// Can edit
@@ -197,7 +197,7 @@ if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled))
print '';
print $langs->trans("MEMBER_PAYONLINE_SENDEMAIL");
print ' ';
- print ' ';;
+ print ' ';
print " \n";
}
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 6aa9e074ff6..0fe6366ae58 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -249,7 +249,7 @@ if (empty($reshook))
}
$lastname=$_POST["lastname"];
$firstname=$_POST["firstname"];
- $morphy=$morphy=$_POST["morphy"];;
+ $morphy=$morphy=$_POST["morphy"];
if ($morphy != 'mor' && empty($lastname)) {
$error++;
$langs->load("errors");
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index c8c4f9b9ad4..941f7b300fd 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -5,8 +5,9 @@
* Copyright (C) 2004 Sebastien Di Cintio
* Copyright (C) 2004 Benoit Mortier
* Copyright (C) 2009-2012 Regis Houssin
- * Copyright (C) 2014 Alexandre Spangaro
+ * Copyright (C) 2014-2015 Alexandre Spangaro
* Copyright (C) 2015 Marcos García
+ * Copyright (C) 2015 Frederic France
*
* 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
@@ -77,7 +78,8 @@ class Adherent extends CommonObject
var $morphy;
var $public;
- var $note; // Private note
+ var $note_private; // Private note
+ var $note_public; // Public note
var $statut; // -1:brouillon, 0:resilie, >=1:valide,paye
var $photo;
@@ -310,7 +312,7 @@ class Adherent extends CommonObject
$sql.= " VALUES (";
$sql.= " '".$this->db->idate($this->datec)."'";
$sql.= ", ".($this->login?"'".$this->db->escape($this->login)."'":"null");
- $sql.= ", ".($user->id>0?$user->id:"null"); // Can be null because member can be createb by a guest or a script
+ $sql.= ", ".($user->id>0?$user->id:"null"); // Can be null because member can be created by a guest or a script
$sql.= ", null, null, '".$this->morphy."'";
$sql.= ", '".$this->typeid."'";
$sql.= ", ".$conf->entity;
@@ -445,9 +447,10 @@ class Adherent extends CommonObject
$sql.= ", email='".$this->email."'";
$sql.= ", skype='".$this->skype."'";
$sql.= ", phone=" .($this->phone?"'".$this->db->escape($this->phone)."'":"null");
- $sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
+ $sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
$sql.= ", phone_mobile=" .($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null");
- $sql.= ", note=" .($this->note?"'".$this->db->escape($this->note)."'":"null");
+ $sql.= ", note_private=" .($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
+ $sql.= ", note_public=" .($this->note_private?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", photo=" .($this->photo?"'".$this->photo."'":"null");
$sql.= ", public='".$this->public."'";
$sql.= ", statut=" .$this->statut;
@@ -473,7 +476,7 @@ class Adherent extends CommonObject
$action='update';
// Actions on extra fields (by external module)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('memberdao'));
$parameters=array('id'=>$this->id);
$action='';
@@ -1053,7 +1056,8 @@ class Adherent extends CommonObject
{
global $langs;
- $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note,";
+ $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
+ $sql.= " d.note_public,";
$sql.= " d.email, d.skype, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,";
$sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
$sql.= " d.datec as datec,";
@@ -1134,7 +1138,8 @@ class Adherent extends CommonObject
$this->datevalid = $this->db->jdate($obj->datev);
$this->birth = $this->db->jdate($obj->birthday);
- $this->note = $obj->note;
+ $this->note_private = $obj->note_private;
+ $this->note_public = $obj->note_public;
$this->morphy = $obj->morphy;
$this->typeid = $obj->fk_adherent_type;
@@ -1561,7 +1566,8 @@ class Adherent extends CommonObject
$result='';
$label = '' . $langs->trans("ShowMember") . ' ';
- $label.= '' . $langs->trans('Ref') . ': ' . $this->ref;
+ if (! empty($this->ref))
+ $label.= '' . $langs->trans('Ref') . ': ' . $this->ref;
if (! empty($this->firstname) || ! empty($this->lastname))
$label.= '' . $langs->trans('Name') . ': ' . $this->getFullName($langs);
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
@@ -1801,7 +1807,7 @@ class Adherent extends CommonObject
$this->phone = '0999999999';
$this->phone_perso = '0999999998';
$this->phone_mobile = '0999999997';
- $this->note='No comment';
+ $this->note_private='No comment';
$this->birth=time();
$this->photo='';
$this->public=1;
@@ -1874,7 +1880,8 @@ class Adherent extends CommonObject
if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
- if ($this->note && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note;
+ if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note_private;
+ if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = $this->note_public;
if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap');
if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
@@ -1947,4 +1954,21 @@ class Adherent extends CommonObject
}
}
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty($db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'adherent'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
+
}
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index cbf5b428cc0..ee15a261820 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -73,7 +73,7 @@ class AdherentType extends CommonObject
{
global $conf;
- $this->statut=trim($this->statut);
+ $this->statut=(int) $this->statut;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
$sql.= "libelle";
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index 41c06beebe9..a94f6750f55 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -110,7 +110,7 @@ if ($sall)
if (is_numeric($sall)) $sql.= "d.rowid = ".$sall." OR ";
$sql.=" d.firstname LIKE '%".$db->escape($sall)."%' OR d.lastname LIKE '%".$db->escape($sall)."%' OR d.societe LIKE '%".$db->escape($sall)."%'";
$sql.=" OR d.email LIKE '%".$db->escape($sall)."%' OR d.login LIKE '%".$db->escape($sall)."%' OR d.address LIKE '%".$db->escape($sall)."%'";
- $sql.=" OR d.town LIKE '%".$db->escape($sall)."%' OR d.note LIKE '%".$db->escape($sall)."%')";
+ $sql.=" OR d.town LIKE '%".$db->escape($sall)."%' OR d.note_public LIKE '%".$db->escape($sall)."%' OR d.note_private LIKE '%".$db->escape($sall)."%')";
}
}
if ($type > 0)
diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php
index 727b3a9bcdc..79b7db086e6 100644
--- a/htdocs/adherents/note.php
+++ b/htdocs/adherents/note.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2004-2014 Laurent Destailleur
+/* Copyright (C) 2004 Rodolphe Quiedeville
+ * Copyright (C) 2004-2014 Laurent Destailleur
+ * Copyright (C) 2015 Frederic France
*
* 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
@@ -19,7 +20,7 @@
/**
* \file htdocs/adherents/note.php
* \ingroup member
- * \brief Tabe for note of a member
+ * \brief Tab for note of a member
*/
require '../main.inc.php';
@@ -45,26 +46,13 @@ if ($result > 0)
$result=$adht->fetch($object->typeid);
}
+$permissionnote=$user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php
/*
* Actions
*/
-if ($action == 'update' && $user->rights->adherent->creer && ! $_POST["cancel"])
-{
- $db->begin();
-
- $res=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
- if ($res < 0)
- {
- setEventMessage($object->error, 'errors');
- $db->rollback();
- }
- else
- {
- $db->commit();
- }
-}
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
@@ -82,7 +70,7 @@ if ($id)
dol_fiche_head($head, 'note', $langs->trans("Member"), 0, 'user');
- print "\n";
+ print ' ';
- /*
- * Actions
- */
- print '';
- print '';
+ $colwidth='20';
+ $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php
+ include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
- if ($user->rights->adherent->creer && $action != 'edit')
- {
- print '
";
- }
-
- print "
";
+ dol_fiche_end();
}
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index 22b8cdbfd68..cdeaa21ba9f 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -386,7 +386,7 @@ if ($rowid > 0)
{
$sql.= " AND (d.firstname LIKE '%".$sall."%' OR d.lastname LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'";
$sql.= " OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.address LIKE '%".$sall."%'";
- $sql.= " OR d.town LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')";
+ $sql.= " OR d.town LIKE '%".$sall."%' OR d.note_public LIKE '%".$sall."%' OR d.note_private LIKE '%".$sall."%')";
}
if ($status != '')
{
diff --git a/htdocs/admin/askpricesupplier.php b/htdocs/admin/askpricesupplier.php
index 6307e81042c..d2072a0c79c 100644
--- a/htdocs/admin/askpricesupplier.php
+++ b/htdocs/admin/askpricesupplier.php
@@ -319,7 +319,6 @@ foreach ($dirmodels as $reldir)
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().' ';
- $askpricesupplier->type=0;
$nextval=$module->getNextValue($mysoc,$askpricesupplier);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index a349973b3dc..b9b2d18d512 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -369,7 +369,7 @@ if ($action == 'edit' || $action == 'updateedit')
// Logo
$var=!$var;
print ''.$langs->trans("Logo").' (png,jpg) ';
- print '';
+ print '';
print ' ';
print ' ';
if (! empty($mysoc->logo_mini))
@@ -605,8 +605,9 @@ if ($action == 'edit' || $action == 'updateedit')
}
print ' ';
+ $opcions=array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"),$langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"),$langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
+
print ''.$langs->trans("CalcLocaltax").': ';
- $opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code));
print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1);
print ' ';
print "
";
@@ -649,7 +650,6 @@ if ($action == 'edit' || $action == 'updateedit')
print ' ';
}
print ''.$langs->trans("CalcLocaltax").' : ';
- $opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code));
print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2);
print ' ';
print "
";
@@ -754,7 +754,7 @@ else
$var=!$var;
print ' '.$langs->trans("Logo").' ';
- print '';
+ print '';
print $mysoc->logo;
print ' ';
@@ -1061,15 +1061,15 @@ else
print ' '.$langs->trans("CalcLocaltax").': ';
if($conf->global->MAIN_INFO_LOCALTAX_CALC2==0)
{
- print $langs->transcountry("CalcLocaltax1",$mysoc->country_code);
+ print $langs->trans("CalcLocaltax1").' - '.$langs->trans("CalcLocaltax1Desc");
}
else if($conf->global->MAIN_INFO_LOCALTAX_CALC2==1)
{
- print $langs->transcountry("CalcLocaltax2",$mysoc->country_code);
+ print $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc");
}
else if($conf->global->MAIN_INFO_LOCALTAX_CALC2==2)
{
- print $langs->transcountry("CalcLocaltax3",$mysoc->country_code);
+ print $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc");
}
print ' ';
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 4c3ac209423..f7c0d2c8bf7 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -923,7 +923,7 @@ if ($id)
print "";
$colspan=count($fieldlist)+2;
- if ($id == 4) $colspan++;;
+ if ($id == 4) $colspan++;
if (! empty($alabelisused)) // Si un des champs est un libelle
{
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index cbbcad66daa..88932c0de44 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -323,8 +323,6 @@ else // Show
$var=true;
// Language
- print_fiche_titre($langs->trans("Language"),'','');
- print ' ';
print '';
print ''.$langs->trans("Parameters").' '.$langs->trans("Value").' ';
diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php
index 6ec184d68ec..4416c8fed8f 100644
--- a/htdocs/admin/index.php
+++ b/htdocs/admin/index.php
@@ -100,6 +100,7 @@ print ' ';
print ' ';
// Add hook to add information
+$parameters=array();
$reshook=$hookmanager->executeHooks('addHomeSetup',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint;
if (empty($reshook))
diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php
index bddf16f8670..8bac5068143 100644
--- a/htdocs/admin/ldap_members.php
+++ b/htdocs/admin/ldap_members.php
@@ -65,13 +65,14 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO',GETPOST("fieldphoneperso"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
- if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
+ if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP',GETPOST("fieldzip"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN',GETPOST("fieldtown"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY',GETPOST("fieldcountry"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++;
+ if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC',GETPOST("fieldnotepublic"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE',GETPOST("fieldbirthdate"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS',GETPOST("fieldstatus"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"),'chaine',0,'',$conf->entity)) $error++;
@@ -312,6 +313,14 @@ print ''.$langs->trans("LDAPFieldDescriptionExample").' ';
print ' ';
print '';
+// Public Note
+$var=!$var;
+print ''.$langs->trans("LDAPFieldNotePublic").' ';
+print ' ';
+print ' '.$langs->trans("LDAPFieldNotePublicExample").' ';
+print ' ';
+print ' ';
+
// Birthday
$var=!$var;
print ''.$langs->trans("LDAPFieldBirthdate").' ';
diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php
index b9c163972ce..c06758cc356 100644
--- a/htdocs/admin/notification.php
+++ b/htdocs/admin/notification.php
@@ -174,8 +174,8 @@ if ($conf->societe->enabled)
print ' '.$notifiedevent['code'].' ';
print ''.$label.' ';
print '';
- $nb = $notify->countDefinedNotifications($notifiedevent['code'], 0);
- print $nb;
+ $tmparray = $notify->getNotificationsArray($notifiedevent['code'], 0);
+ print count($tmparray);
print ' ';
print ' ';
}
diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php
index b56ee74e10f..81ae430b371 100644
--- a/htdocs/admin/prelevement.php
+++ b/htdocs/admin/prelevement.php
@@ -180,7 +180,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION))
$langs->load("mails");
print_titre($langs->trans("Notifications"));
- $sql = "SELECT u.rowid, u.lastname, u.firstname, u.fk_societe, u.email";
+ $sql = "SELECT u.rowid, u.lastname, u.firstname, u.fk_soc, u.email";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE entity IN (0,".$conf->entity.")";
@@ -194,7 +194,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION))
{
$obj = $db->fetch_object($resql);
$var=!$var;
- if (!$obj->fk_societe)
+ if (!$obj->fk_soc)
{
$username=dolGetFirstLastname($obj->firstname,$obj->lastname);
$internalusers[$obj->rowid] = $username;
diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php
index 5a3c3808201..b7c7d3b5c3d 100644
--- a/htdocs/admin/supplier_order.php
+++ b/htdocs/admin/supplier_order.php
@@ -182,43 +182,27 @@ else if ($action == 'set_SUPPLIER_ORDER_OTHER')
$res3=1;
}*/
- // TODO We add/delete permission until permission can have a condition on a global var
- $r_id = 1190;
- $entity = $conf->entity;
- $r_desc=$langs->trans("Permission1190");
- $r_modul='fournisseur';
- $r_type='w';
- $r_perms='commande';
- $r_subperms='approve2';
- $r_def=0;
+ // TODO We add/delete permission here until permission can have a condition on a global var
+ include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php';
+ $newmodule=new modFournisseur($db);
+ // clear default rights array
+ $newmodule->rights=array();
+ // add new right
+ $r=0;
+ $newmodule->rights[$r][0] = 1190;
+ $newmodule->rights[$r][1] = $langs->trans("Permission1190");
+ $newmodule->rights[$r][2] = 'w';
+ $newmodule->rights[$r][3] = 0;
+ $newmodule->rights[$r][4] = 'commande';
+ $newmodule->rights[$r][5] = 'approve2';
if ($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL)
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
- $sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)";
- $sql.= " VALUES ";
- $sql.= "(".$r_id.",".$entity.",'".$db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')";
-
- $resqlinsert=$db->query($sql,1);
- if (! $resqlinsert)
- {
- if ($db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS")
- {
- setEventMessage($db->lasterror(),'errors');
- $error++;
- }
- }
+ $newmodule->insert_permissions(1);
}
else
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def";
- $sql.= " WHERE id = ".$r_id;
- $resqldelete=$db->query($sql,1);
- if (! $resqldelete)
- {
- setEventMessage($db->lasterror(),'errors');
- $error++;
- }
+ $newmodule->delete_permissions();
}
}
diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index aec78f8aaac..c1f44b7c791 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -111,11 +111,6 @@ jQuery(document).ready(function() {
print_fiche_titre($langs->trans("Backup"),'','setup');
print $langs->trans("BackupDesc",DOL_DATA_ROOT).' ';
-print $langs->trans("BackupDesc2",DOL_DATA_ROOT).' ';
-print $langs->trans("BackupDescX").' ';
-print $langs->trans("BackupDesc3",DOL_DATA_ROOT).' ';
-print $langs->trans("BackupDescY").' ';
-
?>
@@ -124,9 +119,29 @@ print $langs->trans("BackupDescY").' ';
name="token" value="" />
-
-'.$langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.' '; ?>
-
+1
+
+trans("BackupDesc3",$dolibarr_main_db_name).' ';
+//print $langs->trans("BackupDescY").' ';
+print ' ';
+?>
+
+
+
+trans("BackupDumpWizard"));
+
+print '
';
+?>
-
+
+
+
admin->dir_output.'/backup','files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1);
$result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/',1,0,$langs->trans("NoBackupFileAvailable"),0,$langs->trans("PreviousDumpFiles"));
print ' ';
+?>
+
+
+
+
+
+
+
+2
+trans("BackupDesc2",DOL_DATA_ROOT).' ';
+print $langs->trans("BackupDescX").' ';
+?>
+
+
+
+
+
+trans("Restore"),'','setup');
print $langs->trans("RestoreDesc",DOL_DATA_ROOT).' ';
+?>
+
+1
+trans("RestoreDesc2",DOL_DATA_ROOT).' ';
-print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).' ';
+?>
+
+
+
+
+2
+trans("RestoreDesc3",$dolibarr_main_db_name).' ';
?>
-
-'.$langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.' '; ?>
+trans("DatabaseName").' : '.$dolibarr_main_db_name.' '; ?>
+
use_javascript_ajax) { ?>
diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php
index 1668e4f4c67..ba3da7b443c 100644
--- a/htdocs/admin/tools/export.php
+++ b/htdocs/admin/tools/export.php
@@ -88,10 +88,10 @@ if (!empty($MemoryLimit))
$form=new Form($db);
$formfile = new FormFile($db);
-$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
-llxHeader('','',$help_url);
+//$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
+//llxHeader('','',$help_url);
-print_fiche_titre($langs->trans("Backup"),'','setup');
+//print_fiche_titre($langs->trans("Backup"),'','setup');
// Start with empty buffer
@@ -165,13 +165,18 @@ if ($what == 'mysql')
$paramclear.=' -p"'.str_replace(array('"','`'),array('\"','\`'),$dolibarr_main_db_pass).'"';
}
+ $_SESSION["commandbackuplastdone"]=$command." ".$paramcrypted;
+ $_SESSION["commandbackuptorun"]="";
+ /*
print ''.$langs->trans("RunCommandSummary").': '."\n";
print ' '."\n";
print ' ';
+
//print $paramclear;
// Now run command and show result
print ''.$langs->trans("BackupResult").': ';
+ */
$errormsg='';
@@ -264,6 +269,9 @@ if ($what == 'mysqlnobin')
{
backup_tables($outputfile);
}
+
+ $_SESSION["commandbackuplastdone"]="";
+ $_SESSION["commandbackuptorun"]="";
}
// POSTGRESQL
@@ -320,7 +328,9 @@ if ($what == 'postgresql')
$paramcrypted.=" -w ".$dolibarr_main_db_name;
$paramclear.=" -w ".$dolibarr_main_db_name;
- print $langs->trans("RunCommandSummaryToLaunch").': '."\n";
+ $_SESSION["commandbackuplastdone"]="";
+ $_SESSION["commandbackuptorun"]=$command." ".$paramcrypted;
+ /*print $langs->trans("RunCommandSummaryToLaunch").': '."\n";
print ' '."\n";
print ' ';
@@ -330,7 +340,7 @@ if ($what == 'postgresql')
print $langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser",$dolibarr_main_db_user,$dolibarr_main_db_user);
print ' ';
- print ' ';
+ print ' ';*/
$what='';
}
@@ -339,34 +349,46 @@ if ($what == 'postgresql')
// Si on a demande une generation
-if ($what)
-{
+//if ($what)
+//{
if ($errormsg)
{
+ setEventMessage($langs->trans("Error")." : ".$errormsg, 'errors');
+ /*
print ''.$langs->trans("Error")." : ".$errormsg.'
';
- // print ''.$langs->trans("DownloadErrorFile").' ';
- print ' ';
print ' ';
+ print ' ';*/
}
else
- {
- print '';
- print $langs->trans("BackupFileSuccessfullyCreated").'. ';
- print $langs->trans("YouCanDownloadBackupFile");
- print '
';
- print ' ';
+ {
+ if ($what)
+ {
+ setEventMessage($langs->trans("BackupFileSuccessfullyCreated").'. '.$langs->trans("YouCanDownloadBackupFile"));
+ /*print '';
+ print $langs->trans("BackupFileSuccessfullyCreated").'. ';
+ print $langs->trans("YouCanDownloadBackupFile");
+ print '
';
+ print ' ';*/
+ }
+ else
+ {
+ setEventMessage($langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser",$dolibarr_main_db_user,$dolibarr_main_db_user));
+ }
}
-}
+//}
+/*
$filearray=dol_dir_list($conf->admin->dir_output.'/backup','files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1);
$result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/',1,0,($langs->trans("NoBackupFileAvailable").' '.$langs->trans("ToBuildBackupFileClickHere",DOL_URL_ROOT.'/admin/tools/dolibarr_export.php')),0,$langs->trans("PreviousDumpFiles"));
print ' ';
+*/
+
+// Redirect t backup page
+header("Location: dolibarr_export.php");
$time_end = time();
-llxFooter();
-
$db->close();
diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php
index 7c85f820eab..27799ff1e93 100644
--- a/htdocs/admin/tools/update.php
+++ b/htdocs/admin/tools/update.php
@@ -29,6 +29,8 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/geturl.lib.php';
$langs->load("admin");
$langs->load("other");
+$action=GETPOST('action','alpha');
+
if (! $user->admin) accessforbidden();
if (GETPOST('msg','alpha')) {
@@ -43,14 +45,18 @@ $dolibarrroot=preg_replace('/([\\/]+)$/i','',DOL_DOCUMENT_ROOT);
$dolibarrroot=preg_replace('/([^\\/]+)$/i','',$dolibarrroot);
$dolibarrdataroot=preg_replace('/([\\/]+)$/i','',DOL_DATA_ROOT);
+$dirins=DOL_DOCUMENT_ROOT.'/custom';
+
+
/*
* Actions
*/
-if (GETPOST('action','alpha')=='install')
+if ($action=='install')
{
$error=0;
+ // $original_file should match format module_modulename-x.y[.z].zip
$original_file=basename($_FILES["fileinstall"]["name"]);
$newfile=$conf->admin->dir_temp.'/'.$original_file.'/'.$original_file;
@@ -72,33 +78,87 @@ if (GETPOST('action','alpha')=='install')
if (! $error)
{
- @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file);
- dol_mkdir($conf->admin->dir_temp.'/'.$original_file);
+ if ($original_file)
+ {
+ @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file);
+ dol_mkdir($conf->admin->dir_temp.'/'.$original_file);
+ }
+
+ $tmpdir=preg_replace('/\.zip$/','',$original_file).'.dir';
+ if ($tmpdir)
+ {
+ @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$tmpdir);
+ dol_mkdir($conf->admin->dir_temp.'/'.$tmpdir);
+ }
$result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'],$newfile,1,0,$_FILES['fileinstall']['error']);
if ($result > 0)
{
- $documentrootalt=DOL_DOCUMENT_ROOT.'/extensions';
- $result=dol_uncompress($newfile,$documentrootalt);
+ $result=dol_uncompress($newfile,$conf->admin->dir_temp.'/'.$tmpdir);
+
if (! empty($result['error']))
{
$langs->load("errors");
setEventMessage($langs->trans($result['error'],$original_file), 'errors');
+ $error++;
}
else
{
- setEventMessage($langs->trans("SetupIsReadyForUse"));
+ // Now we move the dir of the module
+ $modulename=preg_replace('/module_/', '', $original_file);
+ $modulename=preg_replace('/\-[\d]+\.[\d]+.*$/', '', $modulename);
+ // Search dir $modulename
+ $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename;
+ //var_dump($modulenamedir);
+ if (! dol_is_dir($modulenamedir))
+ {
+ $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename;
+ //var_dump($modulenamedir);
+ if (! dol_is_dir($modulenamedir))
+ {
+ setEventMessage($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat"), 'errors');
+ $error++;
+ }
+ }
+
+ if (! $error)
+ {
+ //var_dump($dirins);
+ @dol_delete_dir_recursive($dirins.'/'.$modulename);
+ $result=dolCopyDir($modulenamedir, $dirins.'/'.$modulename, '0444', 1);
+ if ($result <= 0)
+ {
+ setEventMessage($langs->trans("ErrorFailedToCopy"), 'errors');
+ $error++;
+ }
+ }
}
}
+ else
+ {
+ $error++;
+ }
+ }
+
+ if (! $error)
+ {
+ setEventMessage($langs->trans("SetupIsReadyForUse"));
}
}
+
/*
* View
*/
-$dirins=DOL_DOCUMENT_ROOT.'/extensions';
-$dirins_ok=(is_dir($dirins));
+
+
+// Set dir where external modules are installed
+if (! dol_is_dir($dirins))
+{
+ dol_mkdir($dirins);
+}
+$dirins_ok=(dol_is_dir($dirins));
$wikihelp='EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalación_-_Actualización';
llxHeader('',$langs->trans("Upgrade"),$wikihelp);
@@ -143,6 +203,8 @@ else
}
print ' ';
+
+// Upgrade
print $langs->trans("Upgrade").' ';
print ' ';
print $langs->trans("ThisIsProcessToFollow").' ';
@@ -162,20 +224,76 @@ print $langs->trans("RestoreLock",$dolibarrdataroot.'/install.lock').' ';
print ' ';
print ' ';
+
+// Install external module
+
+$allowonlineinstall=true;
+$allowfromweb=1;
+if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false;
+
$fullurl=''.$urldolibarrmodules.' ';
+$message='';
+if (! empty($allowonlineinstall))
+{
+ if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt)))
+ {
+ $message=info_admin($langs->trans("ConfFileMuseContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
+ $allowfromweb=-1;
+ }
+ else
+ {
+ if ($dirins_ok)
+ {
+ if (! is_writable(dol_osencode($dirins)))
+ {
+ $langs->load("errors");
+ $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins));
+ $allowfromweb=0;
+ }
+ }
+ else
+ {
+
+ $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
+ $allowfromweb=0;
+ }
+ }
+}
+else
+{
+ $message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile",$dolibarrdataroot.'/installmodules.lock'));
+ $allowfromweb=0;
+}
+
+
+
+
+
print $langs->trans("AddExtensionThemeModuleOrOther").' ';
print ' ';
-print $langs->trans("ThisIsProcessToFollow").' ';
-print ''.$langs->trans("StepNb",1).' : ';
-print $langs->trans("FindPackageFromWebSite",$fullurl).' ';
-print ''.$langs->trans("StepNb",2).' : ';
-print $langs->trans("DownloadPackageFromWebSite",$fullurl).' ';
-print ''.$langs->trans("StepNb",3).' : ';
-print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).' ';
-if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE))
+
+if ($allowfromweb < 1)
{
- if ($dirins_ok)
+ print $langs->trans("SomethingMakeInstallFromWebNotPossible");
+ print $message;
+ //print $langs->trans("SomethingMakeInstallFromWebNotPossible2");
+ print ' ';
+}
+
+
+if ($allowfromweb >= 0)
+{
+ if ($allowfromweb == 1) print $langs->trans("ThisIsProcessToFollow").' ';
+ else print $langs->trans("ThisIsAlternativeProcessToFollow").' ';
+ print ''.$langs->trans("StepNb",1).' : ';
+ print $langs->trans("FindPackageFromWebSite",$fullurl).' ';
+ print ''.$langs->trans("StepNb",2).' : ';
+ print $langs->trans("DownloadPackageFromWebSite",$fullurl).' ';
+ print ''.$langs->trans("StepNb",3).' : ';
+
+ if ($allowfromweb == 1)
{
+ print $langs->trans("UnpackPackageInDolibarrRoot",$dirins).' ';
print '';
+
if (! empty($result['return']))
{
diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php
index aa92d2bedb9..06490f21cda 100644
--- a/htdocs/bookmarks/class/bookmark.class.php
+++ b/htdocs/bookmarks/class/bookmark.class.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2015 Marcos García
*
* 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
@@ -210,4 +211,21 @@ class Bookmark
}
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'bookmark'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
+
}
diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php
index 7be283528b4..4739a55e2c8 100644
--- a/htdocs/cashdesk/admin/cashdesk.php
+++ b/htdocs/cashdesk/admin/cashdesk.php
@@ -164,7 +164,7 @@ if (! empty($conf->service->enabled))
$var=! $var;
print '';
print $langs->trans("CashdeskShowServices");
- print ' ';;
+ print ' ';
print $form->selectyesno("CASHDESK_SERVICES",$conf->global->CASHDESK_SERVICES,1);
print " \n";
}
diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php
index 76af3708c8b..1cd605ea9ca 100644
--- a/htdocs/categories/categorie.php
+++ b/htdocs/categories/categorie.php
@@ -341,7 +341,7 @@ else if ($id || $ref)
llxHeader("","",$langs->trans("CardProduct".$product->type));
- $head=product_prepare_head($product, $user);
+ $head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'category', $titre,0,$picto);
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 9a76211b828..8e6772dec5d 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -7,6 +7,7 @@
* Copyright (C) 2007 Patrick Raguin
* Copyright (C) 2013 Juanjo Menent
* Copyright (C) 2013 Philippe Grand
+ * Copyright (C) 2015 Marcos García
*
* 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
@@ -201,7 +202,7 @@ class Categorie extends CommonObject
$action='create';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('HookModuleNamedao'));
$parameters=array('socid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@@ -294,7 +295,7 @@ class Categorie extends CommonObject
$action='update';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('HookCategorydao'));
$parameters=array();
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@@ -1164,10 +1165,10 @@ class Categorie extends CommonObject
{
$cats = array();
- $typeid=-1; $table='';;
+ $typeid=-1; $table='';
if ($type == '0' || $type == 'product') { $typeid=0; $table='product'; $type='product'; }
- else if ($type == '1' || $type == 'supplier') { $typeid=1; $table='societe'; $type='fournisseur'; }
- else if ($type == '2' || $type == 'customer') { $typeid=2; $table='societe'; $type='societe'; }
+ else if ($type == '1' || $type == 'supplier') { $typeid=1; $table='soc'; $type='fournisseur'; }
+ else if ($type == '2' || $type == 'customer') { $typeid=2; $table='soc'; $type='societe'; }
else if ($type == '3' || $type == 'member') { $typeid=3; $table='member'; $type='member'; }
else if ($type == '4' || $type == 'contact') { $typeid=4; $table='socpeople'; $type='contact'; }
@@ -1551,4 +1552,21 @@ class Categorie extends CommonObject
$this->socid = 1;
$this->type = 0;
}
+
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'categorie_societe'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
}
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 2e840abce76..543cf862d8f 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -333,7 +333,7 @@ class ActionComm extends CommonObject
$action='create';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@@ -657,7 +657,7 @@ class ActionComm extends CommonObject
$action='update';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@@ -1263,5 +1263,22 @@ class ActionComm extends CommonObject
$this->userassigned[$user->id]=array('id'=>$user->id, 'transparency'=> 1);
}
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'actioncomm'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
+
}
diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php
index e7bddb8bd7e..54f97fa2117 100644
--- a/htdocs/comm/action/class/ical.class.php
+++ b/htdocs/comm/action/class/ical.class.php
@@ -220,8 +220,8 @@ class ICal
}
if (($key == "DTSTAMP") or ($key == "LAST-MODIFIED") or ($key == "CREATED")) $value = $this->ical_date_to_unix($value);
- if ($key == "RRULE" ) $value = $this->ical_rrule($value);
-
+ //if ($key == "RRULE" ) $value = $this->ical_rrule($value);
+
if (stristr($key,"DTSTART") or stristr($key,"DTEND") or stristr($key,"DTSTART;VALUE=DATE") or stristr($key,"DTEND;VALUE=DATE"))
{
if (stristr($key,"DTSTART;VALUE=DATE") or stristr($key,"DTEND;VALUE=DATE"))
diff --git a/htdocs/comm/askpricesupplier/card.php b/htdocs/comm/askpricesupplier/card.php
index 3a3b283f8e9..b87a579b0e8 100644
--- a/htdocs/comm/askpricesupplier/card.php
+++ b/htdocs/comm/askpricesupplier/card.php
@@ -1730,6 +1730,9 @@ if ($action == 'create')
/*
* Action presend
*/
+ if (GETPOST('modelselected')) {
+ $action = 'presend';
+ }
if ($action == 'presend')
{
$object->fetch_projet();
@@ -1802,6 +1805,7 @@ if ($action == 'create')
// Tableau des parametres complementaires
$formmail->param['action'] = 'send';
$formmail->param['models'] = 'askpricesupplier_send';
+ $formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['id'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 14bf6e42fe8..81e8b396963 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -155,7 +155,7 @@ if (empty($reshook))
if ($action == 'setoutstanding_limit')
{
$object->fetch($id);
- $object->outstanding_limit=GETPOST('setoutstanding_limit');
+ $object->outstanding_limit=GETPOST('outstanding_limit');
$result=$object->set_OutstandingBill($user);
if ($result < 0) setEventMessage($object->error,'errors');
}
@@ -406,9 +406,15 @@ if ($id > 0)
$limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : ''));
// display amount and link to unpaid bill
- $outstandigBills = $object->get_OutstandingBill();
- if ($outstandigBills != 0)
- print " (".$langs->trans("CurrentOutstandingBill")." ".price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency).' )';
+ $outstandingBills = $object->get_OutstandingBill();
+ if ($outstandingBills != 0) {
+ print ' ('.$langs->trans("CurrentOutstandingBill");
+ print ' ';
+ print price($outstandingBills, '', $langs, 0, -1, -1, $conf->currency);
+ print ' ';
+ if ($outstandingBills > $object->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
+ print ')';
+ }
print ' ';
print ' ';
}
@@ -627,7 +633,7 @@ if ($id > 0)
print '';
print '';
- print ''.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).' '.$langs->trans("AllOrders").' '.$num.' ';
+ print ''.$langs->trans("LastCustomerOrders",($num<=$MAXLIST?"":$MAXLIST)).' '.$langs->trans("AllOrders").' '.$num.' ';
print ''.img_picto($langs->trans("Statistics"),'stats').' ';
//if($num2 > 0) print ''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').' ';
//else print ''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').' ';
@@ -854,7 +860,7 @@ if ($id > 0)
$facturestatic = new Facture($db);
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount';
- $sql.= ', f.total';
+ $sql.= ', f.total as total_ht';
$sql.= ', f.tva as total_tva';
$sql.= ', f.total_ttc';
$sql.= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut';
@@ -896,7 +902,7 @@ if ($id > 0)
$facturestatic->id = $objp->facid;
$facturestatic->ref = $objp->facnumber;
$facturestatic->type = $objp->type;
- $facturestatic->total_ht = $objp->total;
+ $facturestatic->total_ht = $objp->total_ht;
$facturestatic->total_tva = $objp->total_tva;
$facturestatic->total_ttc = $objp->total_ttc;
print $facturestatic->getNomUrl(1);
@@ -909,7 +915,7 @@ if ($id > 0)
{
print '!!! ';
}
- print ''.price($objp->total_ttc).' ';
+ print ''.price($objp->total_ht).' ';
print ''.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am)).' ';
print " \n";
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index cb5a07c32d3..6705752e71e 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -67,7 +67,7 @@ if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db);
llxHeader();
-print_fiche_titre($langs->trans("CustomerArea"));
+print_fiche_titre($langs->trans("CommercialArea"));
print '';
@@ -579,6 +579,103 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
}
}
+/*
+ * Opened Order
+ */
+if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
+{
+ $langs->load("order");
+
+ $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total as total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv ";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
+ $sql.= ", ".MAIN_DB_PREFIX."commande as c";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE c.fk_soc = s.rowid";
+ $sql.= " AND c.entity = ".$conf->entity;
+ $sql.= " AND c.fk_statut = 1";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+ if ($socid) $sql.= " AND s.rowid = ".$socid;
+ $sql.= " ORDER BY c.rowid DESC";
+
+ $result=$db->query($sql);
+ if ($result)
+ {
+ $total = 0;
+ $num = $db->num_rows($result);
+ $i = 0;
+ if ($num > 0)
+ {
+ $var=true;
+
+ print '
';
+ print ''.$langs->trans("OrdersOpened").' '.$num.' ';
+
+ $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
+ while ($i < $nbofloop)
+ {
+ $obj = $db->fetch_object($result);
+ $var=!$var;
+ print '';
+
+ // Ref
+ print '';
+
+ $orderstatic->id=$obj->commandeid;
+ $orderstatic->ref=$obj->ref;
+ $orderstatic->ref_client=$obj->ref_client;
+ $orderstatic->total_ht = $obj->total_ht;
+ $orderstatic->total_tva = $obj->total_tva;
+ $orderstatic->total_ttc = $obj->total_ttc;
+
+ print '';
+ print '';
+ print $orderstatic->getNomUrl(1);
+ print ' ';
+ print '';
+ //if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
+ print ' ';
+ print '';
+ $filename=dol_sanitizeFileName($obj->ref);
+ $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
+ $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
+ print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir);
+ print '
';
+
+ print " ";
+
+ print '';
+ $companystatic->id=$obj->rowid;
+ $companystatic->name=$obj->name;
+ $companystatic->client=$obj->client;
+ $companystatic->canvas=$obj->canvas;
+ print $companystatic->getNomUrl(1, 'company', 44);
+ print ' ';
+ print '';
+ print dol_print_date($db->jdate($obj->dp),'day').' '."\n";
+ print ''.price($obj->total_ttc).' ';
+ print ''.$orderstatic->LibStatut($obj->fk_statut,3).' '."\n";
+ print ' '."\n";
+ $i++;
+ $total += $obj->total_ttc;
+ }
+ if ($num > $nbofloop)
+ {
+ print ''.$langs->trans("XMoreLines", ($num - $nbofloop))." ";
+ }
+ else if ($total>0)
+ {
+ print ''.$langs->trans("Total")." ".price($total)." ";
+ }
+ print "
";
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+}
+
+
print '
';
diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php
index 06b26d88f48..bc3be7b3ebe 100644
--- a/htdocs/comm/list.php
+++ b/htdocs/comm/list.php
@@ -105,7 +105,7 @@ $sql = "SELECT s.rowid, s.nom as name, s.client, s.zip, s.town, st.libelle as st
$sql.= " s.datec, s.canvas";
if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe"; // We need this table joined to the select in order to filter by categ
+if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
$sql.= " WHERE s.fk_stcomm = st.id";
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index c5288404eec..10d51feb798 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -303,7 +303,7 @@ if (empty($reshook))
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
- $object->statut = 0;
+ $object->statut = Propal::STATUS_DRAFT;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@@ -543,52 +543,80 @@ if (empty($reshook))
}
// Classify billed
- else if ($action == 'classifybilled' && $user->rights->propal->cloturer) {
- $object->cloture($user, 4, '');
+ else if ($action == 'classifybilled' && $user->rights->propal->cloturer)
+ {
+ $result=$object->cloture($user, 4, '');
+ if ($result < 0)
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $error++;
+ }
}
// Reopen proposal
- else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) {
+ else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel'))
+ {
// prevent browser refresh from reopening proposal several times
- if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) {
+ if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) {
$object->reopen($user, 1);
}
}
// Close proposal
- else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) {
+ else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel'))
+ {
if (! GETPOST('statut')) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors');
$action = 'statut';
} else {
// prevent browser refresh from closing proposal several times
- if ($object->statut == 1) {
- $object->cloture($user, GETPOST('statut'), GETPOST('note'));
+ if ($object->statut == Propal::STATUS_VALIDATED)
+ {
+ $result=$object->cloture($user, GETPOST('statut'), GETPOST('note'));
+ if ($result < 0)
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $error++;
+ }
}
}
}
// Classify billed
- else if ($action == 'classifybilled' && $user->rights->propal->cloturer) {
- $object->cloture($user, 4, '');
+ else if ($action == 'classifybilled' && $user->rights->propal->cloturer)
+ {
+ $result=$object->cloture($user, 4, '');
+ if ($result < 0)
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $error++;
+ }
}
// Reopen proposal
- else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) {
+ else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel'))
+ {
// prevent browser refresh from reopening proposal several times
- if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) {
- $object->reopen($user, 1);
+ if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED)
+ {
+ $result=$object->reopen($user, 1);
+ if ($result < 0)
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $error++;
+ }
}
}
// Close proposal
- else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) {
+ else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel'))
+ {
if (! GETPOST('statut')) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors');
$action = 'statut';
} else {
// prevent browser refresh from closing proposal several times
- if ($object->statut == 1) {
+ if ($object->statut == Propal::STATUS_VALIDATED) {
$object->cloture($user, GETPOST('statut'), GETPOST('note'));
}
}
@@ -1154,7 +1182,7 @@ if (empty($reshook))
if (! $error)
{
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('propaldao'));
$parameters = array('id' => $object->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been
@@ -1745,7 +1773,7 @@ if ($action == 'create')
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
if ($absolute_discount) {
- if ($object->statut > 0) {
+ if ($object->statut > Propal::STATUS_DRAFT) {
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount, 0, $langs, 0, 0, -1, $conf->currency));
} else {
// Remise dispo de type non avoir
@@ -1807,7 +1835,7 @@ if ($action == 'create')
} else {
if (! empty($object->fin_validite)) {
print dol_print_date($object->fin_validite, 'daytext');
- if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay))
+ if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay))
print img_warning($langs->trans("Late"));
} else {
print ' ';
@@ -2091,7 +2119,7 @@ if ($action == 'create')
';
- if (! empty($conf->use_javascript_ajax) && $object->statut == 0) {
+ if (! empty($conf->use_javascript_ajax) && $object->statut == Propal::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
@@ -2101,7 +2129,7 @@ if ($action == 'create')
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
// Form to add new line
- if ($object->statut == 0 && $user->rights->propal->creer)
+ if ($object->statut == Propal::STATUS_DRAFT && $user->rights->propal->creer)
{
if ($action != 'editline')
{
@@ -2164,7 +2192,7 @@ if ($action == 'create')
if ($action != 'statut' && $action != 'editline')
{
// Validate
- if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 &&
+ if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
) {
@@ -2178,18 +2206,18 @@ if ($action == 'create')
print '' . $langs->trans("AddAction") . ' ';
}
// Edit
- if ($object->statut == 1 && $user->rights->propal->creer) {
+ if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->creer) {
print '';
}
// ReOpen
- if (($object->statut == 2 || $object->statut == 3 || $object->statut == 4) && $user->rights->propal->cloturer) {
+ if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $user->rights->propal->cloturer) {
print '';
}
// Send
- if ($object->statut == 1 || $object->statut == 2) {
+ if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED) {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) {
print '';
} else
@@ -2197,14 +2225,14 @@ if ($action == 'create')
}
// Create an order
- if (! empty($conf->commande->enabled) && $object->statut == 2) {
+ if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) {
if ($user->rights->commande->creer) {
print '';
}
}
// Create contract
- if ($conf->contrat->enabled && $object->statut == 2) {
+ if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) {
$langs->load("contracts");
if ($user->rights->contrat->creer) {
@@ -2213,7 +2241,8 @@ if ($action == 'create')
}
// Create an invoice and classify billed
- if ($object->statut == 2) {
+ if ($object->statut == Propal::STATUS_SIGNED)
+ {
if (! empty($conf->facture->enabled) && $user->rights->facture->creer)
{
print '';
@@ -2227,7 +2256,7 @@ if ($action == 'create')
}
// Close
- if ($object->statut == 1 && $user->rights->propal->cloturer) {
+ if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->cloturer) {
print '';
}
@@ -2288,6 +2317,10 @@ if ($action == 'create')
/*
* Action presend
*/
+ //Select mail models is same action as presend
+ if (GETPOST('modelselected')) {
+ $action = 'presend';
+ }
if ($action == 'presend')
{
$object->fetch_projet();
@@ -2382,6 +2415,7 @@ if ($action == 'create')
// Tableau des parametres complementaires
$formmail->param['action'] = 'send';
$formmail->param['models'] = 'propal_send';
+ $formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['id'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 0045bc88f91..43379eb221c 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -56,19 +56,56 @@ class Propal extends CommonObject
var $id;
- var $socid; // Id client
- var $client; // Objet societe client (a charger par fetch_client)
+ /**
+ * ID of the client
+ * @var int
+ */
+ var $socid;
+ /**
+ * Client (loaded by fetch_client)
+ * @var Societe
+ */
+ var $client;
var $contactid;
var $fk_project;
var $author;
var $ref;
var $ref_client;
- var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed)
- var $datec; // Date of creation
- var $datev; // Date of validation
- var $date; // Date of proposal
- var $datep; // Same than date
+
+ /**
+ * Status of the quote
+ * Check the following constants:
+ * - STATUS_DRAFT
+ * - STATUS_VALIDATED
+ * - STATUS_SIGNED
+ * - STATUS_NOTSIGNED
+ * - STATUS_BILLED
+ * @var int
+ */
+ var $statut;
+
+ /**
+ * Date of creation
+ * @var
+ */
+ var $datec;
+ /**
+ * Date of validation
+ * @var
+ */
+ var $datev;
+ /**
+ * Date of the quote
+ * @var
+ */
+ var $date;
+
+ /**
+ * Same than date ¿?
+ * @var
+ */
+ var $datep;
var $date_livraison;
var $fin_validite;
@@ -81,9 +118,19 @@ class Propal extends CommonObject
var $total_localtax1; // Total Local Taxes 1
var $total_localtax2; // Total Local Taxes 2
var $total_ttc; // Total with tax
- var $price; // deprecated (for compatibility)
- var $tva; // deprecated (for compatibility)
- var $total; // deprecated (for compatibility)
+
+ /**
+ * @deprecated
+ */
+ var $price;
+ /**
+ * @deprecated
+ */
+ var $tva;
+ /**
+ * @deprecated
+ */
+ var $total;
var $cond_reglement_id;
var $cond_reglement_code;
@@ -93,10 +140,16 @@ class Propal extends CommonObject
var $remise;
var $remise_percent;
var $remise_absolue;
- var $note; // deprecated (for compatibility)
+ /**
+ * @deprecated
+ */
+ var $note;
var $note_private;
var $note_public;
- var $fk_delivery_address; // deprecated (for compatibility)
+ /**
+ * @deprecated
+ */
+ var $fk_delivery_address;
var $fk_address;
var $address_type;
var $address;
@@ -122,12 +175,32 @@ class Propal extends CommonObject
var $labelstatut_short=array();
var $specimen;
-
+
//Incorterms
var $fk_incoterms;
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
+ /**
+ * Draft status
+ */
+ const STATUS_DRAFT = 0;
+ /**
+ * Validated status
+ */
+ const STATUS_VALIDATED = 1;
+ /**
+ * Signed quote
+ */
+ const STATUS_SIGNED = 2;
+ /**
+ * Not signed quote
+ */
+ const STATUS_NOTSIGNED = 3;
+ /**
+ * Billed quote
+ */
+ const STATUS_BILLED = 4;
/**
* Constructor
@@ -365,7 +438,7 @@ class Propal extends CommonObject
// Check parameters
if ($type < 0) return -1;
- if ($this->statut == 0)
+ if ($this->statut == self::STATUS_DRAFT)
{
$this->db->begin();
@@ -531,7 +604,7 @@ class Propal extends CommonObject
if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag
if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag
- if ($this->statut == 0)
+ if ($this->statut == self::STATUS_DRAFT)
{
$this->db->begin();
@@ -657,7 +730,7 @@ class Propal extends CommonObject
*/
function deleteline($lineid)
{
- if ($this->statut == 0)
+ if ($this->statut == self::STATUS_DRAFT)
{
$line=new PropaleLigne($this->db);
@@ -893,7 +966,7 @@ class Propal extends CommonObject
$action='update';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('propaldao'));
$parameters=array('socid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@@ -1015,7 +1088,7 @@ class Propal extends CommonObject
}
$this->id=0;
- $this->statut=0;
+ $this->statut=self::STATUS_DRAFT;
if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
{
@@ -1197,10 +1270,10 @@ class Propal extends CommonObject
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
- $this->location_incoterms = $obj->location_incoterms;
+ $this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
-
- if ($obj->fk_statut == 0)
+
+ if ($obj->fk_statut == self::STATUS_DRAFT)
{
$this->brouillon = 1;
}
@@ -1236,7 +1309,7 @@ class Propal extends CommonObject
$extrafieldsline=new ExtraFields($this->db);
$line = new PropaleLigne($this->db);
$extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true);
-
+
$num = $this->db->num_rows($result);
$i = 0;
@@ -1290,7 +1363,7 @@ class Propal extends CommonObject
$line->date_end = $objp->date_end;
$line->fetch_optionals($line->id,$extralabelsline);
-
+
$this->lines[$i] = $line;
//dol_syslog("1 ".$line->fk_product);
//print "xx $i ".$this->lines[$i]->fk_product;
@@ -1329,7 +1402,7 @@ class Propal extends CommonObject
$action='update';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('propaldao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@@ -1395,8 +1468,8 @@ class Propal extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET ref = '".$num."',";
- $sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
- $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
+ $sql.= " fk_statut = ".self::STATUS_VALIDATED.", date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
+ $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
dol_syslog(get_class($this)."::valid", LOG_DEBUG);
$resql=$this->db->query($sql);
@@ -1451,7 +1524,7 @@ class Propal extends CommonObject
$this->ref=$num;
$this->brouillon=0;
- $this->statut = 1;
+ $this->statut = self::STATUS_VALIDATED;
$this->user_valid_id=$user->id;
$this->datev=$now;
@@ -1486,7 +1559,7 @@ class Propal extends CommonObject
if (! empty($user->rights->propal->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'";
- $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
+ $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
dol_syslog(get_class($this)."::set_date", LOG_DEBUG);
if ($this->db->query($sql) )
@@ -1515,7 +1588,7 @@ class Propal extends CommonObject
if (! empty($user->rights->propal->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null');
- $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
+ $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
if ($this->db->query($sql) )
{
$this->fin_validite = $date_fin_validite;
@@ -1665,7 +1738,7 @@ class Propal extends CommonObject
$remise = price2num($remise);
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise;
- $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
+ $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
if ($this->db->query($sql) )
{
@@ -1699,7 +1772,7 @@ class Propal extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET remise_absolue = ".$remise;
- $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
+ $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
if ($this->db->query($sql) )
{
@@ -1791,7 +1864,6 @@ class Propal extends CommonObject
{
global $langs,$conf;
- $this->statut = $statut;
$error=0;
$now=dol_now();
@@ -1807,7 +1879,7 @@ class Propal extends CommonObject
$modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf;
$trigger_name='PROPAL_CLOSE_REFUSED';
- if ($statut == 2)
+ if ($statut == self::STATUS_SIGNED)
{
$trigger_name='PROPAL_CLOSE_SIGNED';
$modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf;
@@ -1819,12 +1891,12 @@ class Propal extends CommonObject
if ($result < 0)
{
- $this->error=$this->db->error();
+ $this->error=$this->db->lasterror();
$this->db->rollback();
return -2;
}
}
- if ($statut == 4)
+ if ($statut == self::STATUS_BILLED)
{
$trigger_name='PROPAL_CLASSIFY_BILLED';
}
@@ -1850,7 +1922,9 @@ class Propal extends CommonObject
if ( ! $error )
{
- $this->db->commit();
+ $this->statut = $statut;
+
+ $this->db->commit();
return 1;
}
else
@@ -1861,7 +1935,7 @@ class Propal extends CommonObject
}
else
{
- $this->error=$this->db->error();
+ $this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
@@ -1874,11 +1948,11 @@ class Propal extends CommonObject
*/
function classifyBilled()
{
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = 4';
- $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = '.self::STATUS_BILLED;
+ $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT.' ;';
if ($this->db->query($sql) )
{
- $this->statut=4;
+ $this->statut=self::STATUS_BILLED;
return 1;
}
else
@@ -1906,12 +1980,12 @@ class Propal extends CommonObject
*/
function set_draft($user)
{
- $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = ".self::STATUS_DRAFT;
$sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql))
{
- $this->statut = 0;
+ $this->statut = self::STATUS_DRAFT;
$this->brouillon = 1;
return 1;
}
@@ -1955,7 +2029,7 @@ class Propal extends CommonObject
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
if ($socid) $sql.= " AND s.rowid = ".$socid;
- if ($draft) $sql.= " AND p.fk_statut = 0";
+ if ($draft) $sql.= " AND p.fk_statut = ".self::STATUS_DRAFT;
if ($notcurrentuser > 0) $sql.= " AND p.fk_user_author <> ".$user->id;
$sql.= $this->db->order($sortfield,$sortorder);
$sql.= $this->db->plimit($limit,$offset);
@@ -2225,7 +2299,7 @@ class Propal extends CommonObject
function availability($availability_id)
{
dol_syslog('Propale::availability('.$availability_id.')');
- if ($this->statut >= 0)
+ if ($this->statut >= self::STATUS_DRAFT)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql .= ' SET fk_availability = '.$availability_id;
@@ -2259,7 +2333,7 @@ class Propal extends CommonObject
function demand_reason($demand_reason_id)
{
dol_syslog('Propale::demand_reason('.$demand_reason_id.')');
- if ($this->statut >= 0)
+ if ($this->statut >= self::STATUS_DRAFT)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql .= ' SET fk_input_reason = '.$demand_reason_id;
@@ -2366,11 +2440,11 @@ class Propal extends CommonObject
global $langs;
$langs->load("propal");
- if ($statut==0) $statuttrans='statut0';
- if ($statut==1) $statuttrans='statut1';
- if ($statut==2) $statuttrans='statut3';
- if ($statut==3) $statuttrans='statut5';
- if ($statut==4) $statuttrans='statut6';
+ if ($statut==self::STATUS_DRAFT) $statuttrans='statut0';
+ if ($statut==self::STATUS_VALIDATED) $statuttrans='statut1';
+ if ($statut==self::STATUS_SIGNED) $statuttrans='statut3';
+ if ($statut==self::STATUS_NOTSIGNED) $statuttrans='statut5';
+ if ($statut==self::STATUS_BILLED) $statuttrans='statut6';
if ($mode == 0) return $this->labelstatut[$statut];
if ($mode == 1) return $this->labelstatut_short[$statut];
@@ -2403,8 +2477,8 @@ class Propal extends CommonObject
$clause = " AND";
}
$sql.= $clause." p.entity = ".$conf->entity;
- if ($mode == 'opened') $sql.= " AND p.fk_statut = 1";
- if ($mode == 'signed') $sql.= " AND p.fk_statut = 2";
+ if ($mode == 'opened') $sql.= " AND p.fk_statut = ".self::STATUS_VALIDATED;
+ if ($mode == 'signed') $sql.= " AND p.fk_statut = ".self::STATUS_SIGNED;
if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id;
$resql=$this->db->query($sql);
@@ -2415,12 +2489,12 @@ class Propal extends CommonObject
if ($mode == 'opened') {
$delay_warning=$conf->propal->cloture->warning_delay;
- $statut = 1;
+ $statut = self::STATUS_VALIDATED;
$label = $langs->trans("PropalsToClose");
}
if ($mode == 'signed') {
$delay_warning=$conf->propal->facturation->warning_delay;
- $statut = 2;
+ $statut = self::STATUS_SIGNED;
$label = $langs->trans("PropalsToBill");
}
@@ -2806,7 +2880,22 @@ class Propal extends CommonObject
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'propal'
+ );
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
}
@@ -2827,7 +2916,14 @@ class PropaleLigne extends CommonObjectLine
var $fk_parent_line;
var $desc; // Description ligne
var $fk_product; // Id produit predefini
- var $product_type = 0; // Type 0 = product, 1 = Service
+ /**
+ * Product type.
+ * Use the following constants:
+ * - Product::TYPE_PRODUCT
+ * - Product::TYPE_SERVICE
+ * @var int
+ */
+ var $product_type = Product::TYPE_PRODUCT;
var $qty;
var $tva_tx;
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index 9292684d06f..05cd2db3f04 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -126,7 +126,7 @@ if ($id > 0 || ! empty($ref))
if ($object->fin_validite)
{
print dol_print_date($object->fin_validite,'daytext');
- if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
+ if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
}
else
{
diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php
index b2202a21b88..1ab843da188 100644
--- a/htdocs/comm/prospect/list.php
+++ b/htdocs/comm/prospect/list.php
@@ -201,7 +201,7 @@ if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql
$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
-if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe"; // We need this table joined to the select in order to filter by categ
+if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= " WHERE s.fk_stcomm = st.id";
$sql.= " AND s.client IN (2, 3)";
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 162fa01a424..f174ab9e8ff 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1125,7 +1125,7 @@ if (empty($reshook))
if (! $error)
{
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('orderdao'));
$parameters = array('id' => $object->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
@@ -2404,6 +2404,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Tableau des parametres complementaires
$formmail->param['action'] = 'send';
$formmail->param['models'] = 'order_send';
+ $formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['orderid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 9c9322d3ef5..91b17273513 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -53,8 +53,17 @@ class Commande extends CommonOrder
var $id;
- var $socid; // Id client
- var $client; // Objet societe client (a charger par fetch_client)
+ /**
+ * Client ID
+ * @var int
+ */
+ var $socid;
+
+ /**
+ * Client (loaded by fetch_client)
+ * @var Societe
+ */
+ var $client;
var $ref;
var $ref_client;
@@ -71,31 +80,13 @@ class Commande extends CommonOrder
* - STATUS_CLOSED
* @var int
*/
- var $statut; // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Delivered=Sent/Received, billed or not)
+ var $statut;
+ /**
+ * @deprecated
+ */
var $facturee; // deprecated
var $billed; // billed or not
- /**
- * Canceled status
- */
- const STATUS_CANCELED = -1;
- /**
- * Draft status
- */
- const STATUS_DRAFT = 0;
- /**
- * Validated status
- */
- const STATUS_VALIDATED = 1;
- /**
- * Accepted/On process not managed for customer orders
- */
- const STATUS_ACCEPTED = 2;
- /**
- * Closed (Sent/Received, billed or not)
- */
- const STATUS_CLOSED = 3;
-
var $brouillon;
var $cond_reglement_id;
var $cond_reglement_code;
@@ -155,6 +146,27 @@ class Commande extends CommonOrder
*/
const STOCK_NOT_ENOUGH_FOR_ORDER = -3;
+ /**
+ * Canceled status
+ */
+ const STATUS_CANCELED = -1;
+ /**
+ * Draft status
+ */
+ const STATUS_DRAFT = 0;
+ /**
+ * Validated status
+ */
+ const STATUS_VALIDATED = 1;
+ /**
+ * Accepted/On process not managed for customer orders
+ */
+ const STATUS_ACCEPTED = 2;
+ /**
+ * Closed (Sent/Received, billed or not)
+ */
+ const STATUS_CLOSED = 3;
+
/**
* Constructor
@@ -792,7 +804,7 @@ class Commande extends CommonOrder
$this->lines[$i]->fk_fournprice,
$this->lines[$i]->pa_ht,
$this->lines[$i]->label,
- $this->lines[$i]->array_options,
+ $this->lines[$i]->array_options,
$this->lines[$i]->fk_unit
);
if ($result < 0)
@@ -865,28 +877,25 @@ class Commande extends CommonOrder
if (! $error)
{
- $action='create';
+ //$action='create';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
- $hookmanager->initHooks(array('orderdao'));
+ // TODO le hook fait double emploi avec le trigger !!
+ /*$hookmanager->initHooks(array('orderdao'));
$parameters=array('socid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
- {
+ {*/
$result=$this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
+ if ($result < 0) $error++;
+ /* }
}
- else if ($reshook < 0) $error++;
+ else if ($reshook < 0) $error++;*/
}
- if (! $notrigger)
+ if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('ORDER_CREATE',$user);
@@ -894,29 +903,27 @@ class Commande extends CommonOrder
// End call triggers
}
- if (!$error) {
+ if (! $error)
+ {
$this->db->commit();
return $this->id;
}
-
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
-
+ else
+ {
+ $this->db->rollback();
+ return -1*$error;
+ }
}
else
- {
+ {
+ $this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
}
}
else
- {
+ {
dol_print_error($this->db);
$this->db->rollback();
return -1;
@@ -2668,7 +2675,7 @@ class Commande extends CommonOrder
$action='create';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('orderdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@@ -3299,6 +3306,23 @@ class Commande extends CommonOrder
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
+
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'commande'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
}
diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php
index 6ba80304188..ce2bbc5381e 100644
--- a/htdocs/compta/bank/account.php
+++ b/htdocs/compta/bank/account.php
@@ -403,7 +403,7 @@ if ($id > 0 || ! empty($ref))
print ' ';
if ($nbcategories)
{
- print ' '.$langs->trans("Category").': '.$options.' ';
+ print ' '.$langs->trans("Rubrique").': '.$options.' ';
}
print '';
print ' ';
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 900a970d949..b6215165d35 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -781,8 +781,8 @@ class Account extends CommonObject
$result=$this->deleteExtraFields();
if ($result < 0)
{
- return -1;
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
+ return -1;
}
}
diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php
index 96a44ecd354..9f156e5f568 100644
--- a/htdocs/compta/bank/index.php
+++ b/htdocs/compta/bank/index.php
@@ -133,7 +133,7 @@ if (! $found) print ''.$langs->trans("None").'
// Total
foreach ($total as $key=>$solde)
{
- print ' '.$langs->trans("Total ").$key.' '.price($solde, 0, $langs, 0, 0, -1, $key).' ';
+ print ''.$langs->trans("Total").' '.$key.' '.price($solde, 0, $langs, 0, 0, -1, $key).' ';
}
print '
';
@@ -186,7 +186,7 @@ if (! $found)
// Total
foreach ($total as $key=>$solde)
{
- print ''.$langs->trans("Total ").$key.' '.price($solde, 0, $langs, 0, 0, -1, $key).' ';
+ print ''.$langs->trans("Total").' '.$key.' '.price($solde, 0, $langs, 0, 0, -1, $key).' ';
}
print '
';
@@ -253,7 +253,7 @@ if (! $found)
// Total
foreach ($total as $key=>$solde)
{
- print ' '.$langs->trans("Total ").$key.' '.price($solde, 0, $langs, 0, 0, -1, $key).' ';
+ print ''.$langs->trans("Total").' '.$key.' '.price($solde, 0, $langs, 0, 0, -1, $key).' ';
}
print "
";
diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php
index 6f207b198cf..c89f45d0d2c 100644
--- a/htdocs/compta/bank/releve.php
+++ b/htdocs/compta/bank/releve.php
@@ -379,7 +379,7 @@ else
elseif ($links[$key]['type']=='payment_supplier')
{
$paymentsupplierstatic->id=$links[$key]['url_id'];
- $paymentsupplierstatic->ref=$langs->trans("Payment");;
+ $paymentsupplierstatic->ref=$langs->trans("Payment");
print ' '.$paymentsupplierstatic->getNomUrl(1);
$newline=0;
}
diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php
index a1e114430ce..f367149a19c 100644
--- a/htdocs/compta/bank/search.php
+++ b/htdocs/compta/bank/search.php
@@ -178,9 +178,10 @@ if ($resql)
print '
";
diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php
index 5583edbe357..0c2c62c052f 100644
--- a/htdocs/compta/bank/virement.php
+++ b/htdocs/compta/bank/virement.php
@@ -79,7 +79,7 @@ if ($action == 'add')
$accountto=new Account($db);
$accountto->fetch(GETPOST('account_to','int'));
- if ($accountto->id != $accountfrom->id)
+ if (($accountto->id != $accountfrom->id) && ($accountto->currency_code == $accountfrom->currency_code))
{
$db->begin();
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index e57c07bc754..84da04033b7 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -5,13 +5,15 @@
* Copyright (C) 2005 Marc Barilley / Ocebo
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
- * Copyright (C) 2010-2013 Juanjo Menent
+ * Copyright (C) 2010-2015 Juanjo Menent
* Copyright (C) 2012-2013 Christophe Battarel
* Copyright (C) 2012-2013 Cédric Salvador
* Copyright (C) 2012-2014 Raphaël Doursenaud
* Copyright (C) 2013 Jean-Francois FERRY
* Copyright (C) 2013-2014 Florian Henry
- * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2013 Cédric Salvador
+ * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2015 Marcos García
*
* 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
@@ -1077,7 +1079,11 @@ if (empty($reshook))
$array_options = $lines[$i]->array_options;
}
- $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit);
+ // View third's localtaxes for now
+ $localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $object->client);
+ $localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $object->client);
+
+ $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit);
if ($result > 0) {
$lineid = $result;
@@ -1817,7 +1823,7 @@ if (empty($reshook))
if (! $error) {
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('invoicedao'));
$parameters = array('id' => $object->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
@@ -1972,12 +1978,12 @@ if ($action == 'create')
print $soc->getNomUrl(1);
print ' ';
// Outstanding Bill
- $outstandigBills = $soc->get_OutstandingBill();
+ $outstandingBills = $soc->get_OutstandingBill();
print ' (' . $langs->trans('CurrentOutstandingBill') . ': ';
- print price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency);
+ print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
if ($soc->outstanding_limit != '')
{
- if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
+ if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
}
print ')';
@@ -2366,15 +2372,25 @@ if ($action == 'create')
print ' ';
print ' ';
- $newclassname = $classname;
- if ($newclassname == 'Propal')
- $newclassname = 'CommercialProposal';
- elseif ($newclassname == 'Commande')
- $newclassname = 'Order';
- elseif ($newclassname == 'Expedition')
- $newclassname = 'Sending';
- elseif ($newclassname == 'Fichinter')
- $newclassname = 'Intervention';
+ switch ($classname) {
+ case 'Propal':
+ $newclassname = 'CommercialProposal';
+ break;
+ case 'Commande':
+ $newclassname = 'Order';
+ break;
+ case 'Expedition':
+ $newclassname = 'Sending';
+ break;
+ case 'Contrat':
+ $newclassname = 'Contract';
+ break;
+ case 'Fichinter':
+ $newclassname = 'Intervention';
+ break;
+ default:
+ $newclassname = $classname;
+ }
print '' . $langs->trans($newclassname) . ' ' . $objectsrc->getNomUrl(1);
//We check if Origin document has already an invoice attached to it
@@ -2828,11 +2844,11 @@ if ($action == 'create')
print ' ';
print '(' . $langs->trans('OtherBills') . ' ';
// Outstanding Bill
- $outstandigBills = $soc->get_OutstandingBill();
+ $outstandingBills = $soc->get_OutstandingBill();
print ' - ' . $langs->trans('CurrentOutstandingBill') . ': ';
- print price($outstandigBills, '', $langs, 0, 0, - 1, $conf->currency);
+ print price($outstandingBills, '', $langs, 0, 0, - 1, $conf->currency);
if ($soc->outstanding_limit != '') {
- if ($outstandigBills > $soc->outstanding_limit)
+ if ($outstandingBills > $soc->outstanding_limit)
print img_warning($langs->trans("OutstandingBillReached"));
print ' / ' . price($soc->outstanding_limit);
}
@@ -3729,6 +3745,10 @@ if ($action == 'create')
}
print ' ';
+ //Select mail models is same action as presend
+ if (GETPOST('modelselected')) {
+ $action = 'presend';
+ }
if ($action != 'prerelance' && $action != 'presend')
{
print '';
@@ -3949,6 +3969,7 @@ if ($action == 'create')
// Tableau des parametres complementaires du post
$formmail->param['action'] = $action;
$formmail->param['models'] = $modelmail;
+ $formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['facid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 94053299f79..077299baa7d 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -5,6 +5,7 @@
* Copyright (C) 2010-2011 Juanjo Menent
* Copyright (C) 2012 Cedric Salvador
* Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2015 Marcos García
*
* 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
@@ -599,5 +600,21 @@ class FactureRec extends Facture
$this->usenewprice = 1;
}
-
+
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'facture_rec'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 9f81fc4420c..920f165f83f 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -137,7 +137,7 @@ class Facture extends CommonInvoice
var $specimen;
var $fac_rec;
-
+
//Incoterms
var $fk_incoterms;
var $location_incoterms;
@@ -563,7 +563,7 @@ class Facture extends CommonInvoice
$action='create';
// Actions on extra fields (by external module or standard code)
- // FIXME le hook fait double emploi avec le trigger !!
+ // TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('invoicedao'));
$parameters=array('invoiceid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
@@ -1045,9 +1045,9 @@ class Facture extends CommonInvoice
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
- $this->location_incoterms = $obj->location_incoterms;
+ $this->location_incoterms = $obj->location_incoterms;
$this->libelle_incoterms = $obj->libelle_incoterms;
-
+
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for invoice
@@ -3618,7 +3618,7 @@ class Facture extends CommonInvoice
$this->db->commit();
return 1;
} else {
- $this->error = $this->db->error();
+ $this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::update Error setFinal " . $sql, LOG_ERR);
$this->db->rollback();
return -1;
@@ -3641,12 +3641,29 @@ class Facture extends CommonInvoice
$last = $res['max(situation_counter)'];
return ($last == $this->situation_counter);
} else {
- $this->error = $this->db->error();
+ $this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
+
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'facture'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
}
/**
diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/mergepdftool.php
similarity index 88%
rename from htdocs/compta/facture/impayees.php
rename to htdocs/compta/facture/mergepdftool.php
index d91b52b2166..3f3315fda04 100644
--- a/htdocs/compta/facture/impayees.php
+++ b/htdocs/compta/facture/mergepdftool.php
@@ -1,7 +1,7 @@
* Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2004-2014 Laurent Destailleur
+ * Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2012 Cédric Salvador
* Copyright (C) 2014 Raphaël Doursenaud
@@ -24,17 +24,19 @@
*/
/**
- * \file htdocs/compta/facture/impayees.php
+ * \file htdocs/compta/facture/mergepdftool.php
* \ingroup facture
- * \brief Page to list and build liste of unpaid invoices
+ * \brief Page to list and build doc of selected invoices
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->load("mails");
$langs->load("bills");
@@ -44,6 +46,18 @@ $action = GETPOST('action','alpha');
$option = GETPOST('option');
$mode=GETPOST('mode');
$builddoc_generatebutton=GETPOST('builddoc_generatebutton');
+$month = GETPOST("month","int");
+$year = GETPOST("year","int");
+$filter = GETPOST("filtre");
+if (GETPOST('button_search'))
+{
+ $filter=GETPOST('filtre',2);
+ if ($filter != 'payed:0') $option='';
+}
+if ($option == 'late') $filter = 'paye:0';
+if ($option == 'unpaidall') $filter = 'paye:0';
+if ($mode == 'sendremind' && $filter == '') $filter = 'paye:0';
+if ($filter == '') $filter = 'paye:0';
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@@ -54,6 +68,20 @@ if (! $user->rights->societe->client->voir || $socid) $diroutputpdf.='/private/'
$resultmasssend='';
+if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test must be present to be compatible with all browsers
+{
+ $search_ref="";
+ $search_ref_supplier="";
+ $search_label="";
+ $search_company="";
+ $search_amount_no_tax="";
+ $search_amount_all_tax="";
+ $year="";
+ $month="";
+ $filter="";
+}
+
+
/*
* Action
@@ -297,8 +325,14 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
dol_mkdir($diroutputpdf);
// Save merged file
- $filename=strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
- if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
+ $filename=strtolower(dol_sanitizeFileName($langs->transnoentities("Invoices")));
+ if ($filter=='paye:0')
+ {
+ if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
+ else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
+ }
+ if ($year) $filename.='_'.$year;
+ if ($month) $filename.='_'.$month;
if ($pagecount)
{
$now=dol_now();
@@ -306,6 +340,9 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
+
+ $langs->load("exports");
+ setEventMessage($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')));
}
else
{
@@ -340,9 +377,9 @@ if ($action == 'remove_file')
$form = new Form($db);
$formfile = new FormFile($db);
+$formother = new FormOther($db);
-$title=$langs->trans("BillsCustomersUnpaid");
-if ($option=='late') $title=$langs->trans("BillsCustomersUnpaid");
+$title=$langs->trans("MergingPDFTool");
llxHeader('',$title);
@@ -410,14 +447,15 @@ $sql.= ",".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
-$sql.= " AND f.type IN (0,1,3,5) AND f.fk_statut = 1";
-$sql.= " AND f.paye = 0";
+$sql.= " AND f.type IN (0,1,3,5)";
+if ($filter == 'paye:0') $sql.= " AND f.fk_statut = 1";
+//$sql.= " AND f.paye = 0";
if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
-if (GETPOST('filtre'))
+if ($filter && $filter != -1) // GETPOST('filtre') may be a string
{
- $filtrearr = explode(",", GETPOST('filtre'));
+ $filtrearr = explode(",", $filter);
foreach ($filtrearr as $fil)
{
$filt = explode(":", $fil);
@@ -427,10 +465,21 @@ if (GETPOST('filtre'))
if ($search_ref) $sql .= " AND f.facnumber LIKE '%".$db->escape($search_ref)."%'";
if ($search_refcustomer) $sql .= " AND f.ref_client LIKE '%".$db->escape($search_refcustomer)."%'";
if ($search_societe) $sql .= " AND s.nom LIKE '%".$db->escape($search_societe)."%'";
-if ($search_paymentmode) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode."";
+if ($search_paymentmode) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode."";
if ($search_montant_ht) $sql .= " AND f.total = '".$db->escape($search_montant_ht)."'";
if ($search_montant_ttc) $sql .= " AND f.total_ttc = '".$db->escape($search_montant_ttc)."'";
if (GETPOST('sf_ref')) $sql .= " AND f.facnumber LIKE '%".$db->escape(GETPOST('sf_ref'))."%'";
+if ($month > 0)
+{
+ if ($year > 0)
+ $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
+ else
+ $sql.= " AND date_format(f.datef, '%m') = '$month'";
+}
+else if ($year > 0)
+{
+ $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
+}
$sql.= " GROUP BY s.nom, s.rowid, s.email, f.rowid, f.facnumber, f.ref_client, f.increment, f.total, f.tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp,";
$sql.= " f.datef, f.date_lim_reglement, f.paye, f.fk_statut, f.type, fk_mode_reglement";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
@@ -438,7 +487,7 @@ $sql.= " ORDER BY ";
$listfield=explode(',',$sortfield);
foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.",";
$sql.= " f.facnumber DESC";
-
+//print $sql;
//$sql .= $db->plimit($limit+1,$offset);
$resql = $db->query($sql);
@@ -454,30 +503,36 @@ if ($resql)
$param="";
$param.=(! empty($socid)?"&socid=".$socid:"");
- $param.=(! empty($option)?"&option=".$option:"");
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
- if ($search_refcustomer) $param.='&search_ref='.urlencode($search_refcustomer);
+ if ($search_refcustomer) $param.='&search_ref='.urlencode($search_refcustomer);
if ($search_societe) $param.='&search_societe='.urlencode($search_societe);
if ($search_societe) $param.='&search_paymentmode='.urlencode($search_paymentmode);
if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht);
if ($search_montant_ttc) $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
if ($late) $param.='&late='.urlencode($late);
-
+ if ($mode) $param.='&mode='.urlencode($mode);
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&','&',$param);
- $titre=(! empty($socid)?$langs->trans("BillsCustomersUnpaidForCompany",$soc->name):$langs->trans("BillsCustomersUnpaid"));
+ //$titre=(! empty($socid)?$langs->trans("BillsCustomersUnpaidForCompany",$soc->name):$langs->trans("BillsCustomersUnpaid"));
+ $titre=(! empty($socid)?$langs->trans("BillsCustomersForCompany",$soc->name):$langs->trans("BillsCustomers"));
if ($option == 'late') $titre.=' ('.$langs->trans("Late").')';
- else $titre.=' ('.$langs->trans("All").')';
+ //else $titre.=' ('.$langs->trans("All").')';
$link='';
- if (empty($option)) $link=''.$langs->trans("ShowUnpaidLateOnly").' ';
- elseif ($option == 'late') $link=''.$langs->trans("ShowUnpaidAll").' ';
+ if (empty($option) || $option == 'late') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidAll").' ';
+ if (empty($option) || $option == 'unpaidall') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidLateOnly").' ';
+
+ $param.=(! empty($option)?"&option=".$option:"");
+
print_fiche_titre($titre,$link);
//print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',0); // We don't want pagination on this page
print ' ';
print " \n";
if ($num > 0)
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 698676829d1..d0d2bbb2f8f 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2001-2005 Rodolphe Quiedeville
* Copyright (C) 2004-2013 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2015 Juanjo Menent
*
* 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
@@ -321,7 +322,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.= " AND f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
- $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid";
+ $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid, s.code_client";
$sql.= " ORDER BY f.tms DESC ";
$sql.= $db->plimit($max, 0);
@@ -426,7 +427,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
$sql.= " AND ff.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql.= " AND ff.fk_soc = ".$socid;
- $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_ttc, ff.tms, ff.paye, s.nom, s.rowid";
+ $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye, s.nom, s.rowid, s.code_fournisseur";
$sql.= " ORDER BY ff.tms DESC ";
$sql.= $db->plimit($max, 0);
@@ -658,7 +659,7 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
$sql.= " AND c.fk_statut = 3";
$sql.= " AND c.facture = 0";
- $sql.= " GROUP BY s.nom, s.rowid, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.total_ttc";
+ $sql.= " GROUP BY s.nom, s.rowid, s.code_client, c.rowid, c.ref, c.facture, c.fk_statut, c.tva, c.total_ht, c.total_ttc";
$resql = $db->query($sql);
if ( $resql )
@@ -762,7 +763,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.= " AND f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
- $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid";
+ $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid, s.code_client";
$sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
$resql = $db->query($sql);
@@ -876,8 +877,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
$sql.= " AND ff.fk_statut = 1";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql.= " AND ff.fk_soc = ".$socid;
- $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_ttc, ff.paye,";
- $sql.= " s.nom, s.rowid";
+ $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye,";
+ $sql.= " s.nom, s.rowid, s.code_client, s.code_fournisseur";
$resql=$db->query($sql);
if ($resql)
diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php
index 994e3cca40c..04461117271 100644
--- a/htdocs/compta/localtax/class/localtax.class.php
+++ b/htdocs/compta/localtax/class/localtax.class.php
@@ -109,13 +109,21 @@ class Localtax extends CommonObject
if ($result < 0) $error++;
// End call triggers
- //FIXME: Add rollback if trigger fail
-
- return $this->id;
+ if (! $error)
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
}
else
- {
+ {
$this->error="Error ".$this->db->lasterror();
+ $this->db->rollback();
return -1;
}
}
@@ -141,7 +149,9 @@ class Localtax extends CommonObject
$this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif);
- // Update request
+ $this->db->begin();
+
+ // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."localtax SET";
$sql.= " localtaxtype=".$this->ltt.",";
$sql.= " tms=".$this->db->idate($this->tms).",";
@@ -160,20 +170,27 @@ class Localtax extends CommonObject
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
- return -1;
+ $error++;
}
- if (! $notrigger)
+ if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('LOCALTAX_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
-
- //FIXME: Add rollback if trigger fail
}
- return 1;
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
}
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 883110e9d5b..077bbde2420 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -70,9 +70,10 @@ class Paiement extends CommonObject
* Load payment from database
*
* @param int $id Id of payment to get
+ * @param int $ref Ref of payment to get (same as $id)
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- function fetch($id)
+ function fetch($id, $ref='')
{
$sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,';
$sql.= ' c.code as type_code, c.libelle as type_libelle,';
@@ -81,7 +82,10 @@ class Paiement extends CommonObject
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid ';
$sql.= ' WHERE p.fk_paiement = c.id';
- $sql.= ' AND p.rowid = '.$id;
+ if ($ref)
+ $sql.= ' AND p.rowid = '.$ref;
+ else
+ $sql.= ' AND p.rowid = '.$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php
index 2b71c5c8004..0cc1b3d2f94 100644
--- a/htdocs/compta/prelevement/class/ligneprelevement.class.php
+++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2005 Rodolphe Quiedeville
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2010-2011 Juanjo Menent
+ * Copyright (C) 2015 Marcos García
*
* 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
@@ -61,7 +62,7 @@ class LignePrelevement
* Recupere l'objet prelevement
*
* @param int $rowid id de la facture a recuperer
- * @return void|int
+ * @return integer
*/
function fetch($rowid)
{
@@ -156,5 +157,22 @@ class LignePrelevement
if ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut8');
}
}
+
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'prelevement_lignes'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
}
diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php
index 0db00c10c7f..f7da679196b 100644
--- a/htdocs/compta/salaries/class/paymentsalary.class.php
+++ b/htdocs/compta/salaries/class/paymentsalary.class.php
@@ -95,6 +95,8 @@ class PaymentSalary extends CommonObject
return -1;
}
+ $this->db->begin();
+
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET";
@@ -129,11 +131,18 @@ class PaymentSalary extends CommonObject
$result=$this->call_trigger('PAYMENT_SALARY_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
-
- //FIXME: Add rollback if trigger fail
}
- return 1;
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
}
diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php
index 484010c9f03..81788f2d9de 100644
--- a/htdocs/compta/salaries/index.php
+++ b/htdocs/compta/salaries/index.php
@@ -83,7 +83,7 @@ $form = new Form($db);
$salstatic = new PaymentSalary($db);
$userstatic = new User($db);
-$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_societe as fk_soc,";
+$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc,";
$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,";
$sql.= " pst.code as payment_code";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php
index ad5af8f84c2..f87791dfed9 100644
--- a/htdocs/compta/sociales/document.php
+++ b/htdocs/compta/sociales/document.php
@@ -88,8 +88,8 @@ llxHeader("",$langs->trans("SocialContribution"),$help_url);
if ($object->id)
{
$alreadypayed=$object->getSommePaiement();
-
- $head=tax_prepare_head($object, $user);
+
+ $head=tax_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), 0, 'bill');
diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php
index a4c4663dc40..0f352defc5e 100644
--- a/htdocs/compta/stats/casoc.php
+++ b/htdocs/compta/stats/casoc.php
@@ -183,7 +183,7 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
if ($selected_cat === -2) // Without any category
{
- $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe";
+ $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";
}
else if ($selected_cat) // Into a specific category
{
@@ -201,13 +201,13 @@ if ($modecompta == 'CREANCES-DETTES') {
}
if ($selected_cat === -2) // Without any category
{
- $sql.=" AND cs.fk_societe is null";
+ $sql.=" AND cs.fk_soc is null";
}
else if ($selected_cat) { // Into a specific category
$sql.= " AND (c.rowid = ".$selected_cat;
if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat;
$sql.= ")";
- $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_societe = s.rowid";
+ $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
}
} else {
/*
@@ -221,7 +221,7 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if ($selected_cat === -2) // Without any category
{
- $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe";
+ $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";
}
else if ($selected_cat) // Into a specific category
{
@@ -235,13 +235,13 @@ if ($modecompta == 'CREANCES-DETTES') {
}
if ($selected_cat === -2) // Without any category
{
- $sql.=" AND cs.fk_societe is null";
+ $sql.=" AND cs.fk_soc is null";
}
else if ($selected_cat) { // Into a specific category
$sql.= " AND (c.rowid = ".$selected_cat;
if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat;
$sql.= ")";
- $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_societe = s.rowid";
+ $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
}
}
$sql.= " AND f.entity = ".$conf->entity;
diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php
index f704ca90f73..a44cb4ed48e 100644
--- a/htdocs/compta/stats/index.php
+++ b/htdocs/compta/stats/index.php
@@ -298,7 +298,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
if ($annee_decalage != $year_end) print ' ';
}
- $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0;;
+ $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0;
$total[$annee]+=$cum[$case];
}
diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php
index 948b5096fa3..fa8a71a24e4 100644
--- a/htdocs/compta/tva/class/tva.class.php
+++ b/htdocs/compta/tva/class/tva.class.php
@@ -89,7 +89,9 @@ class Tva extends CommonObject
// Check parameters
// Put here code to add control on parameters values
- // Insert request
+ $this->db->begin();
+
+ // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva(";
$sql.= "tms,";
$sql.= "datep,";
@@ -126,13 +128,22 @@ class Tva extends CommonObject
if ($result < 0) $error++;
// End call triggers
- //FIXME: Add rollback if trigger fail
- return $this->id;
+ if (! $error)
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
}
else
- {
- $this->error="Error ".$this->db->lasterror();
- return -1;
+ {
+ $this->error="Error ".$this->db->lasterror();
+ $this->db->rollback();
+ return -1;
}
}
@@ -160,7 +171,9 @@ class Tva extends CommonObject
// Check parameters
// Put here code to add control on parameters values
- // Update request
+ $this->db->begin();
+
+ // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
$sql.= " tms=".$this->db->idate($this->tms).",";
@@ -181,20 +194,27 @@ class Tva extends CommonObject
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
- return -1;
+ $error++;
}
- if (! $notrigger)
+ if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('TVA_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
-
- //FIXME: Add rollback if trigger fail
}
- return 1;
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
}
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index f8ebe12cd9b..5936e596fb7 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -255,7 +255,7 @@ if (empty($reshook))
}
else
{
- setEventMessage($object->error,$object->errors,'errors');
+ setEventMessages($object->error,$object->errors,'errors');
}
}
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 19ea13f6a39..a61b0ea37bf 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -8,6 +8,7 @@
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2013 Alexandre Spangaro
* Copyright (C) 2013 Juanjo Menent
+ * Copyright (C) 2015 Marcos García
*
* 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
@@ -1084,4 +1085,20 @@ class Contact extends CommonObject
}
}
-}
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'socpeople'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
+}
\ No newline at end of file
diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php
index 970f3543c45..2241a1e67f1 100644
--- a/htdocs/contact/document.php
+++ b/htdocs/contact/document.php
@@ -79,7 +79,7 @@ llxHeader("",$langs->trans("Contact"), $helpurl);
if ($object->id)
{
- $head = contact_prepare_head($object, $user);
+ $head = contact_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans("Contact"), 0, 'contact');
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 0d44703782c..a3c3e6c2c6e 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -973,6 +973,8 @@ if ($action == 'create')
print ' '."\n";
print ' ';
+ dol_fiche_head();
+
print '';
// Ref
@@ -1068,7 +1070,9 @@ if ($action == 'create')
print "
\n";
- print '
';
+ dol_fiche_end();
+
+ print '
';
if (is_object($objectsrc))
{
@@ -1080,10 +1084,8 @@ if ($action == 'create')
print ' '.$langs->trans("Note").': '.$langs->trans("OnlyLinesWithTypeServiceAreUsed");
}
}
-
+
print "\n";
-
- dol_fiche_end();
}
else
/* *************************************************************************** */
@@ -1285,7 +1287,9 @@ else
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
- // Title line for service
+ $var=false;
+
+ // Title line for service
$cursorline=1;
while ($cursorline <= $nbofservices)
{
@@ -1326,8 +1330,6 @@ else
print ' ';
print "\n";
- $var=true;
-
$objp = $db->fetch_object($result);
$var=!$var;
@@ -1355,12 +1357,12 @@ else
}
else
{
- print "".dol_htmlentitiesbr($objp->description)." \n";
+ print ''.dol_htmlentitiesbr($objp->description)." \n";
}
// TVA
print ''.vatrate($objp->tva_tx,'%',$objp->info_bits).' ';
// Prix
- print ''.price($objp->subprice)." \n";
+ print ''.($objp->subprice != '' ? price($objp->subprice) : '')." \n";
// Quantite
print ''.$objp->qty.' ';
//Unit
@@ -1368,7 +1370,7 @@ else
// Remise
if ($objp->remise_percent > 0)
{
- print ''.$objp->remise_percent."% \n";
+ print ''.$objp->remise_percent."% \n";
}
else
{
@@ -1515,7 +1517,7 @@ else
print '';
print $langs->trans("DateStartPlanned").' ';
$form->select_date($db->jdate($objp->date_debut),"date_start_update",$usehm,$usehm,($db->jdate($objp->date_debut)>0?0:1),"update");
- print ' '.$langs->trans("DateEndPlanned").' ';
+ print ' '.$langs->trans("DateEndPlanned").' ';
$form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update");
print ' ';
@@ -1539,7 +1541,7 @@ else
if ($object->statut > 0)
{
- print '';
+ print ' ';
print ' ';
print " \n";
}
@@ -1555,7 +1557,7 @@ else
if ($action == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == GETPOST('rowid'))
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'),$langs->trans("DeleteContractLine"),$langs->trans("ConfirmDeleteContractLine"),"confirm_deleteline",'',0,1);
- if ($ret == 'html') print '';
+ if ($ret == 'html') print '';
}
/*
@@ -1575,7 +1577,7 @@ else
array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid));
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'),$langs->trans("MoveToAnotherContract"),$langs->trans("ConfirmMoveToAnotherContract"),"confirm_move",$formquestion);
- print '';
+ print '';
}
/*
@@ -1587,7 +1589,7 @@ else
$dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
$comment = GETPOST('comment');
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment),$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",dol_print_date($dateactstart,"%A %d %B %Y")),"confirm_active", '', 0, 1);
- print '';
+ print '';
}
/*
@@ -1599,7 +1601,7 @@ else
$dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
$comment = GETPOST('comment');
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService",dol_print_date($dateactend,"%A %d %B %Y")), "confirm_closeline", '', 0, 1);
- print '';
+ print '';
}
@@ -1608,7 +1610,7 @@ else
{
print '';
- print '';
+ print ' ';
print ''.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).' ';
print '';
if ($user->societe_id == 0)
@@ -1625,7 +1627,7 @@ else
print ' ';
print " \n";
- print '';
+ print ' ';
print '';
// Si pas encore active
@@ -1664,7 +1666,7 @@ else
print '
\n";
dol_fiche_end();
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index b8694e44ad4..ce07c25a515 100755
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -7,7 +7,7 @@
* Copyright (C) 2010-2013 Juanjo Menent
* Copyright (C) 2012 Cedric Salvador
* Copyright (C) 2013-2014 Cedric GROSS
- * Copyright (C) 2013-2014 Marcos García
+ * Copyright (C) 2013-2015 Marcos García
* Copyright (C) 2011-2014 Alexandre Spangaro
* Copyright (C) 2014 Henry Florian
* Copyright (C) 2014 Philippe Grand
@@ -3157,6 +3157,8 @@ class Product extends CommonObject
else
{
$this->error=$movementstock->error;
+ $this->errors=$movementstock->errors;
+
$this->db->rollback();
return -1;
}
@@ -3209,9 +3211,10 @@ class Product extends CommonObject
}
/**
- * Load information about stock of a product into stock_warehouse[] and stock_reel
+ * Load information about stock of a product into stock_reel, stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products)
*
- * @return int < 0 if KO, > 0 if OK
+ * @return int < 0 if KO, > 0 if OK
+ * @see load_virtual_stock, getBatchInfo
*/
function load_stock()
{
@@ -3259,9 +3262,10 @@ class Product extends CommonObject
}
/**
- * Load information about virtual stock of a product
+ * Load information about objects that are delat between physical and virtual stock of a product
*
- * @return int < 0 if KO, > 0 if OK
+ * @return int < 0 if KO, > 0 if OK
+ * @see load_stock, getBatchInfo
*/
function load_virtual_stock()
{
@@ -3317,6 +3321,44 @@ class Product extends CommonObject
}
}
+
+ /**
+ * Load existing information about a serial
+ *
+ * @param string $batch Lot/serial number
+ * @return array Array with record into product_batch
+ * @see load_stock, load_virtual_stock
+ */
+ function loadBatchInfo($batch)
+ {
+ $result=array();
+
+ $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) FROM ".MAIN_DB_PREFIX."product_batch as pb, ".MAIN_DB_PREFIX."product_stock as ps";
+ $sql.= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$this->id." AND pb.batch = '".$this->db->escape($batch)."'";
+ $sql.= " GROUP BY pb.batch, pb.eatby, pb.sellby";
+ dol_syslog(get_class($this)."::loadBatchInfo load first entry found for lot/serial = ".$batch, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i=0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $result[]=array('batch'=>$batch, 'eatby'=>$this->db->jdate($obj->eatby), 'sellby'=>$this->db->jdate($obj->sellby), 'qty'=>$obj->qty);
+ $i++;
+ }
+ return $result;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ $this->db->rollback();
+ return array();
+ }
+ }
+
+
/**
* Move an uploaded file described into $file array into target directory $sdir.
*
@@ -3700,7 +3742,7 @@ class Product extends CommonObject
*/
function isproduct()
{
- return ($this->type != Product::TYPE_PRODUCT ? true : false);
+ return ($this->type == Product::TYPE_PRODUCT ? true : false);
}
/**
@@ -3858,4 +3900,22 @@ class Product extends CommonObject
return $maxpricesupplier;
}
+
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'product_customer_price',
+ 'product_customer_price_log'
+ );
+
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
}
diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php
index d6d848b8ef1..ee49302407d 100644
--- a/htdocs/product/class/productbatch.class.php
+++ b/htdocs/product/class/productbatch.class.php
@@ -462,7 +462,7 @@ class Productbatch extends CommonObject
/**
* Return all batch detail records for given product and warehouse
*
- * @param obj $db database object
+ * @param DoliDB $db database object
* @param int $fk_product_stock id product_stock for objet
* @param int $with_qty doesn't return line with 0 quantity
* @return int <0 if KO, >0 if OK
diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php
new file mode 100644
index 00000000000..b2b7296d311
--- /dev/null
+++ b/htdocs/product/class/propalmergepdfproduct.class.php
@@ -0,0 +1,656 @@
+
+ * Copyright (C) 2015 Florian HENRY
+ *
+ * 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/product/class/propalmergepdfproduct.class.php
+ * \ingroup product
+ * \brief This file is an CRUD class file (Create/Read/Update/Delete)
+ */
+
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
+
+
+
+/**
+ * Put here description of your class
+ */
+class Propalmergepdfproduct extends CommonObject
+{
+ var $db; //!< To store db handler
+ var $error; //!< To return error code (or message)
+ var $errors=array(); //!< To return several error codes (or messages)
+ var $element='propal_merge_pdf_product'; //!< Id that identify managed objects
+ var $table_element='propal_merge_pdf_product'; //!< Name of table without prefix where object is stored
+
+ var $id;
+
+ var $fk_product;
+ var $file_name;
+ var $fk_user_author;
+ var $fk_user_mod;
+ var $datec='';
+ var $tms='';
+ var $import_key;
+ var $lang;
+
+ var $lines=array();
+
+
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDb $db Database handler
+ */
+ function __construct($db)
+ {
+ $this->db = $db;
+ return 1;
+ }
+
+
+ /**
+ * Create object into database
+ *
+ * @param User $user User that creates
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, Id of created object if OK
+ */
+ function create($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ // Clean parameters
+
+ if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
+ if (isset($this->file_name)) $this->file_name=trim($this->file_name);
+ if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author);
+ if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
+ if (isset($this->lang)) $this->lang=trim($this->lang);
+ if (isset($this->import_key)) $this->import_key=trim($this->import_key);
+
+
+
+ // Check parameters
+ // Put here code to add control on parameters values
+
+ // Insert request
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_merge_pdf_product(";
+
+ $sql.= "fk_product,";
+ $sql.= "file_name,";
+ if ($conf->global->MAIN_MULTILANGS) {
+ $sql.= "lang,";
+ }
+ $sql.= "fk_user_author,";
+ $sql.= "fk_user_mod,";
+ $sql.= "datec";
+
+
+ $sql.= ") VALUES (";
+
+ $sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->fk_product."'").",";
+ $sql.= " ".(! isset($this->file_name)?'NULL':"'".$this->db->escape($this->file_name)."'").",";
+ if ($conf->global->MAIN_MULTILANGS) {
+ $sql.= " ".(! isset($this->lang)?'NULL':"'".$this->db->escape($this->lang)."'").",";
+ }
+ $sql.= " ".$user->id.",";
+ $sql.= " ".$user->id.",";
+ $sql.= " '".$this->db->idate(dol_now())."'";
+
+
+ $sql.= ")";
+
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product");
+
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ }
+
+
+ /**
+ * Load object in memory from the database
+ *
+ * @param int $id Id object
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch($id)
+ {
+ global $langs,$conf;
+
+ $sql = "SELECT";
+ $sql.= " t.rowid,";
+
+ $sql.= " t.fk_product,";
+ $sql.= " t.file_name,";
+ $sql.= " t.lang,";
+ $sql.= " t.fk_user_author,";
+ $sql.= " t.fk_user_mod,";
+ $sql.= " t.datec,";
+ $sql.= " t.tms,";
+ $sql.= " t.import_key";
+
+
+ $sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
+ $sql.= " WHERE t.rowid = ".$id;
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+
+ $this->fk_product = $obj->fk_product;
+ $this->file_name = $obj->file_name;
+ if ($conf->global->MAIN_MULTILANGS) {
+ $this->lang = $obj->lang;
+ }
+ $this->fk_user_author = $obj->fk_user_author;
+ $this->fk_user_mod = $obj->fk_user_mod;
+ $this->datec = $this->db->jdate($obj->datec);
+ $this->tms = $this->db->jdate($obj->tms);
+ $this->import_key = $obj->import_key;
+
+
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+
+ /**
+ * Load object in memory from the database
+ *
+ * @param int $id Id object
+ * @param string $lang lang string id
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch_by_product($product_id, $lang='')
+ {
+ global $langs,$conf;
+
+ $sql = "SELECT";
+ $sql.= " t.rowid,";
+
+ $sql.= " t.fk_product,";
+ $sql.= " t.file_name,";
+ $sql.= " t.lang,";
+ $sql.= " t.fk_user_author,";
+ $sql.= " t.fk_user_mod,";
+ $sql.= " t.datec,";
+ $sql.= " t.tms,";
+ $sql.= " t.import_key";
+
+
+ $sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
+ $sql.= " WHERE t.fk_product = ".$product_id;
+ if ($conf->global->MAIN_MULTILANGS && !empty($lang)) {
+ $sql.= " AND t.lang = '".$lang."'";
+ }
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ while($obj = $this->db->fetch_object($resql)) {
+
+ $line = new PropalmergepdfproductLine();
+
+ $line->id = $obj->rowid;
+
+ $line->fk_product = $obj->fk_product;
+ $line->file_name = $obj->file_name;
+ if ($conf->global->MAIN_MULTILANGS) {
+ $line->lang = $obj->lang;
+ }
+ $line->fk_user_author = $obj->fk_user_author;
+ $line->fk_user_mod = $obj->fk_user_mod;
+ $line->datec = $this->db->jdate($obj->datec);
+ $line->tms = $this->db->jdate($obj->tms);
+ $line->import_key = $obj->import_key;
+
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $this->lines[$obj->file_name.'_'.$obj->lang]=$line;
+ }else {
+ $this->lines[$obj->file_name]=$line;
+ }
+
+
+ }
+
+
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+
+
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modifies
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function update($user=0, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ // Clean parameters
+
+ if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
+ if (isset($this->file_name)) $this->file_name=trim($this->file_name);
+ if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
+ if (isset($this->lang)) $this->lang=trim($this->lang);
+
+
+
+
+ // Check parameters
+ // Put here code to add a control on parameters values
+
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."propal_merge_pdf_product SET";
+
+ $sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null").",";
+ $sql.= " file_name=".(isset($this->file_name)?"'".$this->db->escape($this->file_name)."'":"null").",";
+ if ($conf->global->MAIN_MULTILANGS) {
+ $sql.= " lang=".(isset($this->lang)?"'".$this->db->escape($this->lang)."'":"null").",";
+ }
+ $sql.= " fk_user_mod=".$user->id;
+
+
+ $sql.= " WHERE rowid=".$this->id;
+
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function delete($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ $this->db->begin();
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
+ $sql.= " WHERE rowid=".$this->id;
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @param int $product_id product_id
+ * @param string $lang_id language
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function delete_by_product($user, $product_id, $lang_id='', $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ $this->db->begin();
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
+ $sql.= " WHERE fk_product=".$product_id;
+
+ if ($conf->global->MAIN_MULTILANGS && !empty($lang_id)) {
+ $sql.= " AND lang='".$lang_id."'";
+ }
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @return int <0 if KO, >0 if OK
+ */
+ function delete_by_file($user)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ $this->db->begin();
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
+ $sql.= " WHERE fk_product=".$this->fk_product." AND file_name='".$this->db->escape($this->file_name)."'";
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+
+
+ /**
+ * Load an object from its id and create a new one in database
+ *
+ * @param int $fromid Id of object to clone
+ * @return int New id of clone
+ */
+ function createFromClone($fromid)
+ {
+ global $user,$langs;
+
+ $error=0;
+
+ $object=new Propalmergepdfproduct($this->db);
+
+ $this->db->begin();
+
+ // Load source object
+ $object->fetch($fromid);
+ $object->id=0;
+ $object->statut=0;
+
+ // Clear fields
+ // ...
+
+ // Create clone
+ $result=$object->create($user);
+
+ // Other options
+ if ($result < 0)
+ {
+ $this->error=$object->error;
+ $error++;
+ }
+
+ if (! $error)
+ {
+
+
+ }
+
+ // End
+ if (! $error)
+ {
+ $this->db->commit();
+ return $object->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
+
+ /**
+ * Initialise object with example values
+ * Id must be 0 if object instance is a specimen
+ *
+ * @return void
+ */
+ function initAsSpecimen()
+ {
+ $this->id=0;
+
+ $this->fk_product='';
+ $this->file_name='';
+ $this->fk_user_author='';
+ $this->fk_user_mod='';
+ $this->datec='';
+ $this->tms='';
+ $this->import_key='';
+
+
+ }
+
+}
+
+class PropalmergepdfproductLine{
+ var $id;
+
+ var $fk_product;
+ var $file_name;
+ var $lang;
+ var $fk_user_author;
+ var $fk_user_mod;
+ var $datec='';
+ var $tms='';
+ var $import_key;
+
+ function __construct() {
+ return 1;
+ }
+
+}
diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php
index 96f2a589429..773d08fae72 100644
--- a/htdocs/product/composition/card.php
+++ b/htdocs/product/composition/card.php
@@ -174,7 +174,7 @@ if ($action == 'search')
llxHeader("","",$langs->trans("CardProduct".$object->type));
-$head=product_prepare_head($object, $user);
+$head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'subproduct', $titre, 0, $picto);
@@ -268,7 +268,7 @@ if ($id > 0 || ! empty($ref))
$productstatic->type=$value["fk_product_type"];
$productstatic->ref=$value['label'];
print '';
- print ''.$productstatic->getNomUrl(1,'composition').' ';;
+ print ''.$productstatic->getNomUrl(1,'composition').' ';
print ' ';
}
print '
';
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index 9a71eac4f55..615f4accf70 100644
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -33,6 +33,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
+ require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
$langs->load("other");
$langs->load("products");
@@ -84,8 +86,70 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
+ //Delete line if product propal merge is linked to a file
+ if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) {
+ if ($action == 'confirm_deletefile' && $confirm == 'yes')
+ {
+ print 'toto';
+ //extract file name
+ $urlfile = GETPOST('urlfile', 'alpha');
+ $filename = basename($urlfile);
+ $filetomerge = new Propalmergepdfproduct($db);
+ $filetomerge->fk_product=$object->id;
+ $filetomerge->file_name=$filename;
+ $result=$filetomerge->delete_by_file($user);
+ if ($result<0) {
+ setEventMessage($filetomerge->error,'errors');
+ }
+ }
+ }
+
// Action sending file
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php';
+
+}
+
+if ($action=='filemerge') {
+ $is_refresh = GETPOST('refresh');
+ if (empty($is_refresh)) {
+
+ $filetomerge_file_array = GETPOST('filetoadd');
+
+ $filetomerge_file_array = GETPOST('filetoadd');
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $lang_id = GETPOST('lang_id');
+ }
+
+ // Delete all file already associated
+ $filetomerge = new Propalmergepdfproduct($db);
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $result=$filetomerge->delete_by_product($user, $object->id, $lang_id);
+ } else {
+ $result=$filetomerge->delete_by_product($user, $object->id);
+ }
+ if ($result<0) {
+ setEventMessage($filetomerge->error,'errors');
+ }
+
+ // for each file checked add it to the product
+ if (is_array($filetomerge_file_array)) {
+ foreach ( $filetomerge_file_array as $filetomerge_file ) {
+ $filetomerge->fk_product = $object->id;
+ $filetomerge->file_name = $filetomerge_file;
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $filetomerge->lang = $lang_id;
+ }
+
+ $result=$filetomerge->create($user);
+ if ($result<0) {
+ setEventMessage($filetomerge->error,'errors');
+ }
+ }
+ }
+ }
}
@@ -100,7 +164,7 @@ llxHeader("","",$langs->trans("CardProduct".$object->type));
if ($object->id)
{
- $head=product_prepare_head($object, $user);
+ $head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'documents', $titre, 0, $picto);
@@ -142,13 +206,139 @@ if ($object->id)
print ''.$langs->trans("NbOfAttachedFiles").' '.count($filearray).' ';
print ''.$langs->trans("TotalSizeOfAttachedFiles").' '.$totalsize.' '.$langs->trans("bytes").' ';
print '
';
-
+
print '';
$modulepart = 'produit';
$permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
+
+
+ //Merge propal PDF docuemnt PDF files
+ if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
+ {
+ $filetomerge = new Propalmergepdfproduct($db);
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $lang_id = GETPOST('lang_id');
+ $result = $filetomerge->fetch_by_product($object->id, $lang_id);
+ } else {
+ $result = $filetomerge->fetch_by_product($object->id);
+ }
+
+ $form = new Form($db);
+
+ $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1);
+
+ // For each file build select list with PDF extention
+ if (count($filearray) > 0) {
+ print ' ';
+ // Actual file to merge is :
+ if (count($filetomerge->lines) > 0) {
+ print $langs->trans('PropalMergePdfProductActualFile');
+ }
+
+ print '';
+ print ' ';
+ print ' ';
+ if (count($filetomerge->lines) == 0) {
+ print $langs->trans('PropalMergePdfProductChooseFile');
+ }
+
+ print '';
+
+ // Get language
+ if ($conf->global->MAIN_MULTILANGS) {
+
+ $langs->load("languages");
+
+ print '';
+
+ $delauft_lang = (empty($lang_id)) ? $langs->getDefaultLang() : $lang_id;
+
+ $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
+
+ print '';
+
+ asort($langs_available);
+
+ $uncompletelanguages = array (
+ 'da_DA',
+ 'fi_FI',
+ 'hu_HU',
+ 'is_IS',
+ 'pl_PL',
+ 'ro_RO',
+ 'ru_RU',
+ 'sv_SV',
+ 'tr_TR',
+ 'zh_CN'
+ );
+ foreach ( $langs_available as $key => $value ) {
+ if ($showwarning && in_array($key, $uncompletelanguages)) {
+ // $value.=' - '.$langs->trans("TranslationUncomplete",$key);
+ }
+ if ($filter && is_array($filter)) {
+ if (! array_key_exists($key, $filter)) {
+ print '' . $value . ' ';
+ }
+ } else if ($delauft_lang == $key) {
+ print '' . $value . ' ';
+ } else {
+ print '' . $value . ' ';
+ }
+ }
+ print ' ';
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ print ' ';
+ }
+
+ print ' ';
+ }
+
+ $style = 'impair';
+ foreach ( $filearray as $filetoadd ) {
+
+ if ($ext = pathinfo($filetoadd['name'], PATHINFO_EXTENSION) == 'pdf') {
+
+ if ($style == 'pair') {
+ $style = 'impair';
+ } else {
+ $style = 'pair';
+ }
+
+ $checked = '';
+ $filename = $filetoadd['name'];
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) {
+ $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $delauft_lang);
+ $checked = ' checked="checked" ';
+ }
+ } else {
+ if (array_key_exists($filetoadd['name'], $filetomerge->lines)) {
+ $checked = ' checked="checked" ';
+ }
+ }
+
+ print '';
+
+ print ' ' . $filename . '';
+ print ' ';
+ }
+ }
+ print '';
+
+ print ' ';
+ print ' ';
+ print '
';
+
+ print ' ';
+ }
+ }
+
}
else
{
@@ -157,4 +347,4 @@ else
llxFooter();
-$db->close();
+$db->close();
\ No newline at end of file
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index c2196aba00b..9d7a9215ef1 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -43,6 +43,7 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$rowid=GETPOST('rowid','int');
$action=GETPOST('action', 'alpha');
+$cancel=GETPOST('cancel', 'alpha');
$socid=GETPOST('socid', 'int');
$backtopage=GETPOST('backtopage','alpha');
$error=0;
@@ -77,6 +78,8 @@ if (! $sortorder) $sortorder="ASC";
* Actions
*/
+if ($cancel) $action='';
+
$parameters=array('socid'=>$socid, 'id_prod'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -97,59 +100,70 @@ if (empty($reshook))
}
}
-if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
-{
- $id_fourn=GETPOST("id_fourn");
- if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn");
- $ref_fourn=GETPOST("ref_fourn");
- if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn");
- $quantity=GETPOST("qty");
- $remise_percent=price2num(GETPOST('remise_percent','alpha'));
- $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ;
- $tva_tx = str_replace('*','', GETPOST('tva_tx','alpha'));
- $tva_tx = price2num($tva_tx);
- $price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode
- $delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : '';
+ if ($action == 'updateprice')
+ {
+ $id_fourn=GETPOST("id_fourn");
+ if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn");
+ $ref_fourn=GETPOST("ref_fourn");
+ if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn");
+ $quantity=GETPOST("qty");
+ $remise_percent=price2num(GETPOST('remise_percent','alpha'));
+ $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ;
+ $tva_tx = str_replace('*','', GETPOST('tva_tx','alpha'));
+ $tva_tx = price2num($tva_tx);
+ $price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode
+ $delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : '';
- if ($tva_tx == '')
- {
- $error++;
- setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("VATRateForSupplierProduct")), 'errors');
- }
- if (empty($quantity))
- {
- $error++;
- setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")), 'errors');
- }
- if (empty($ref_fourn))
- {
- $error++;
- setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")), 'errors');
- }
- if ($id_fourn <= 0)
- {
- $error++;
- setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")), 'errors');
- }
- if ($_POST["price"] < 0 || $_POST["price"] == '')
- {
- if ($price_expression === '') // Return error of missing price only if price_expression not set
+ if ($tva_tx == '')
{
$error++;
- setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")), 'errors');
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("VATRateForSupplierProduct")), 'errors');
}
- else
+ if (! is_numeric($tva_tx))
{
- $_POST["price"] = 0;
+ $error++;
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorFieldMustBeANumeric",'eeee'), 'errors');
}
- }
-
+ if (empty($quantity))
+ {
+ $error++;
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")), 'errors');
+ }
+ if (empty($ref_fourn))
+ {
+ $error++;
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")), 'errors');
+ }
+ if ($id_fourn <= 0)
+ {
+ $error++;
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")), 'errors');
+ }
+ if ($_POST["price"] < 0 || $_POST["price"] == '')
+ {
+ if ($price_expression === '') // Return error of missing price only if price_expression not set
+ {
+ $error++;
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")), 'errors');
+ }
+ else
+ {
+ $_POST["price"] = 0;
+ }
+ }
+
$product = new ProductFournisseur($db);
$result=$product->fetch($id);
if ($result <= 0)
{
$error++;
- setEventMessage($product->error, 'errors');
+ setEventMessages($product->error, $product->errors, 'errors');
}
if (! $error)
@@ -187,11 +201,11 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
{
$error++;
- setEventMessage($product->error, 'errors');
+ setEventMessage($product->error, $product->errors, 'errors');
}
else
{
- if ($price_expression !== '')
+ if ($price_expression !== '')
{
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
@@ -222,13 +236,10 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
$db->rollback();
}
}
- }
-
- if (GETPOST('cancel') == $langs->trans("Cancel"))
- {
- $action = '';
- header("Location: fournisseurs.php?id=".$_GET["id"]);
- exit;
+ else
+ {
+ $action = 'add_price';
+ }
}
}
@@ -253,11 +264,7 @@ if ($id || $ref)
{
if ($action <> 'edit' && $action <> 're-edit')
{
- /*
- * En mode visu
- */
-
- $head=product_prepare_head($product, $user);
+ $head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'suppliers', $titre, 0, $picto);
@@ -323,8 +330,10 @@ if ($id || $ref)
$supplier->fetch($socid);
print $supplier->getNomUrl(1);
print ' ';
- print ' ';
+ print ' ';
print ' ';
+ print ' ';
+ print ' ';
}
else
{
@@ -380,7 +389,7 @@ if ($id || $ref)
{
print ' ';
}
- print '';
+ print '';
// Vat rate
$default_vat='';
@@ -450,7 +459,7 @@ if ($id || $ref)
print '';
print '';
-
+
// Delai livraison jours
print '';
print ''.$langs->trans('NbDaysToDelivery').' ';
@@ -487,11 +496,7 @@ if ($id || $ref)
print '';
}
- /* ************************************************************************** */
- /* */
- /* Barre d'action */
- /* */
- /* ************************************************************************** */
+ // Actions buttons
print "\n\n";
@@ -523,13 +528,9 @@ if ($id || $ref)
print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,'align="right"',$sortfield,$sortorder);
print '
'.$langs->trans("VATRate").' ';
print ''.$langs->trans("PriceQtyMinHT").' ';
- // Charges ????
- if ($conf->global->PRODUCT_CHARGES)
- {
- if (! empty($conf->margin->enabled)) print ''.$langs->trans("Charges").' ';
- }
print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder);
print ''.$langs->trans("DiscountQtyMin").' ';
+ print_liste_field_titre($langs->trans("NbDaysToDelivery"),$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder);
// Charges ????
if ($conf->global->PRODUCT_CHARGES)
{
@@ -601,6 +602,11 @@ if ($id || $ref)
print price2num($productfourn->fourn_remise_percent).'%';
print '';
+ // Delivery delay
+ print '';
+ print $productfourn->delivery_time_days;
+ print ' ';
+
// Charges ????
if ($conf->global->PRODUCT_CHARGES)
{
diff --git a/htdocs/product/index.php b/htdocs/product/index.php
index 90ec2e76fd1..b98470b272d 100644
--- a/htdocs/product/index.php
+++ b/htdocs/product/index.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2014 Regis Houssin
* Copyright (C) 2014 Charles-Fr BENKE
*
@@ -383,7 +383,6 @@ function activitytrim($product_type)
$result = $db->query($sql);
if ($result)
{
- //$tmpyear=$beginyear; // FIXME $beginyear is not defined
$tmpyear=0;
$trim1=0;
$trim2=0;
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index f9503778411..ededdbaff01 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -476,8 +476,11 @@ else
{
if ($product_fourn->product_fourn_price_id > 0)
{
- $htmltext=$product_fourn->display_price_product_fournisseur();
- if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) print $form->textwithpicto(price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"),$htmltext);
+ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
+ {
+ $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1);
+ print $form->textwithpicto(price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"),$htmltext);
+ }
else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT");
}
}
diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php
index 8a6e2ddbd6b..c6245cf203c 100644
--- a/htdocs/product/photos.php
+++ b/htdocs/product/photos.php
@@ -100,7 +100,7 @@ if ($object->id)
/*
* En mode visu
*/
- $head=product_prepare_head($object, $user);
+ $head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'photos', $titre, 0, $picto);
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index 3e7ba24d3dd..2c9ab9a7794 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -353,7 +353,7 @@ if (! empty($id) || ! empty($ref))
llxHeader("", "", $langs->trans("CardProduct" . $object->type));
-$head = product_prepare_head($object, $user);
+$head = product_prepare_head($object);
$titre = $langs->trans("CardProduct" . $object->type);
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
dol_fiche_head($head, 'price', $titre, 0, $picto);
diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php
index ab184cdf943..be38eda6b2d 100644
--- a/htdocs/product/reassort.php
+++ b/htdocs/product/reassort.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2013 Cédric Salvador
*
@@ -102,13 +102,12 @@ $title=$langs->trans("ProductsAndServices");
$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,';
$sql.= ' p.fk_product_type, p.tms as datem,';
-$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte,';
+$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
$sql.= ' SUM(s.reel) as stock_physique';
-$sql .= ', p.desiredstock';
-$sql.= ' FROM ('.MAIN_DB_PREFIX.'product as p';
+$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
+$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product';
// We'll need this table joined to the select in order to filter by categ
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp";
-$sql.= ') LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product';
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
if ($sall)
@@ -156,10 +155,8 @@ if ($search_categ)
$sql .= " AND cp.fk_categorie = ".$db->escape($search_categ);
}
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,";
-$sql.= " p.fk_product_type, p.tms,";
-$sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte";
-$sql .= ", p.desiredstock";
-if ($toolowstock) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet
+$sql.= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock";
+if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; // Not used yet
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
@@ -247,19 +244,19 @@ if ($resql)
print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'align="right"',$sortfield,$sortorder);
// TODO Add info of running suppliers/customers orders
- //print_liste_field_titre($langs->trans("TheoreticalStock"),"reassort.php", "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder);
+ //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder);
print ' ';
- print_liste_field_titre($langs->trans("Sell"),"reassort.php", "p.tosell",$param,"",'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Buy"),"reassort.php", "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Sell"),$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Buy"),$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder);
print " \n";
// Lignes des champs de filtre
print '';
print '';
- print ' ';
+ print ' ';
print ' ';
print '';
- print ' ';
+ print ' ';
print ' ';
if (! empty($conf->service->enabled) && $type == 1)
{
@@ -267,6 +264,7 @@ if ($resql)
print ' ';
print '';
}
+ // Lot/Serial
print ' ';
print ' ';
print ' ';
diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php
new file mode 100644
index 00000000000..451e4302f05
--- /dev/null
+++ b/htdocs/product/reassortlot.php
@@ -0,0 +1,388 @@
+
+ * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2013 Cédric Salvador
+ *
+ * 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/product/reassortlot.php
+ * \ingroup produit
+ * \brief Page to list stocks
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
+
+$langs->load("products");
+$langs->load("stocks");
+$langs->load("productbatch");
+
+// Security check
+if ($user->societe_id) $socid=$user->societe_id;
+$result=restrictedArea($user,'produit|service');
+
+
+$action=GETPOST('action','alpha');
+$sref=GETPOST("sref");
+$snom=GETPOST("snom");
+$sall=GETPOST("sall");
+$type=GETPOST("type","int");
+$sbarcode=GETPOST("sbarcode");
+$search_batch=GETPOST('search_batch');
+$catid=GETPOST('catid','int');
+$toolowstock=GETPOST('toolowstock');
+$tosell = GETPOST("tosell");
+$tobuy = GETPOST("tobuy");
+$fourn_id = GETPOST("fourn_id",'int');
+
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if (! $sortfield) $sortfield="stock_physique";
+if (! $sortorder) $sortorder="ASC";
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+
+// Load sale and categ filters
+$search_sale = GETPOST("search_sale");
+$search_categ = GETPOST("search_categ");
+
+// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
+$canvas=GETPOST("canvas");
+$objcanvas=null;
+if (! empty($canvas))
+{
+ require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
+ $objcanvas = new Canvas($db,$action);
+ $objcanvas->getCanvas('product','list',$canvas);
+}
+
+if (! empty($_POST["button_removefilter_x"]))
+{
+ $sref="";
+ $snom="";
+ $sall="";
+ $search_sale="";
+ $search_categ="";
+ $type="";
+ $catid='';
+ $toolowstock='';
+}
+
+
+
+/*
+ * Actions
+ */
+
+// None
+
+
+/*
+ * View
+ */
+
+$htmlother=new FormOther($db);
+
+$title=$langs->trans("ProductsAndServices");
+
+$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,';
+$sql.= ' p.fk_product_type, p.tms as datem,';
+$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
+$sql.= ' s.fk_entrepot,';
+$sql.= ' pb.batch, pb.eatby, pb.sellby,';
+$sql.= ' SUM(pb.qty) as stock_physique';
+$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
+$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product';
+$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = s.rowid';
+// We'll need this table joined to the select in order to filter by categ
+if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp";
+$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
+if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
+if ($sall)
+{
+ $sql.= " AND (p.ref LIKE '%".$db->escape($sall)."%' OR p.label LIKE '%".$db->escape($sall)."%' OR p.description LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%')";
+}
+// if the type is not 1, we show all products (type = 0,2,3)
+if (dol_strlen($type))
+{
+ if ($type==1)
+ {
+ $sql.= " AND p.fk_product_type = '1'";
+ }
+ else
+ {
+ $sql.= " AND p.fk_product_type <> '1'";
+ }
+}
+if ($sref) $sql.= " AND p.ref LIKE '%".$sref."%'";
+if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'";
+if ($snom) $sql.= " AND p.label LIKE '%".$db->escape($snom)."%'";
+if (! empty($tosell))
+{
+ $sql.= " AND p.tosell = ".$tosell;
+}
+if (! empty($tobuy))
+{
+ $sql.= " AND p.tobuy = ".$tobuy;
+}
+if (! empty($canvas))
+{
+ $sql.= " AND p.canvas = '".$db->escape($canvas)."'";
+}
+if($catid)
+{
+ $sql.= " AND cp.fk_categorie = ".$catid;
+}
+if ($fourn_id > 0)
+{
+ $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
+}
+// Insert categ filter
+if ($search_categ)
+{
+ $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ);
+}
+if ($search_batch)
+{
+ $sql .= " AND pb.batch LIKE '%".$db->escape($search_batch)."%'";
+}
+$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,";
+$sql.= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,";
+$sql.= " s.fk_entrepot,";
+$sql.= " pb.batch, pb.eatby, pb.sellby";
+if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; // Not used yet
+$sql.= $db->order($sortfield,$sortorder);
+$sql.= $db->plimit($limit + 1, $offset);
+$resql = $db->query($sql);
+
+if ($resql)
+{
+ $num = $db->num_rows($resql);
+
+ $i = 0;
+
+ if ($num == 1 && ($sall or $snom or $sref))
+ {
+ $objp = $db->fetch_object($resql);
+ header("Location: card.php?id=$objp->rowid");
+ exit;
+ }
+
+ $helpurl='';
+ $helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
+
+ if (isset($type))
+ {
+ if ($type==1) { $texte = $langs->trans("Services"); }
+ else { $texte = $langs->trans("Products"); }
+ } else {
+ $texte = $langs->trans("ProductsAndServices");
+ }
+ $texte.=' ('.$langs->trans("StocksByLotSerial").')';
+
+
+ llxHeader("",$title,$helpurl,$texte);
+
+ if ($sref || $snom || $sall || GETPOST('search'))
+ {
+ print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num);
+ }
+ else
+ {
+ print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num);
+ }
+
+ if (! empty($catid))
+ {
+ print "";
+ $c = new Categorie($db);
+ $c->fetch($catid);
+ $ways = $c->print_all_ways(' > ','product/reassortlot.php');
+ print " > ".$ways[0]." \n";
+ print "
";
+ }
+
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+
+ print '';
+
+ // Filter on categories
+ $moreforfilter='';
+ if (! empty($conf->categorie->enabled))
+ {
+ $moreforfilter.=$langs->trans('Categories'). ': ';
+ $moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ');
+ $moreforfilter.=' ';
+ }
+ //$moreforfilter.=$langs->trans("StockTooLow").' ';
+ if ($moreforfilter)
+ {
+ print '';
+ print '';
+ print $moreforfilter;
+ print ' ';
+ }
+
+ $param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref&batch=$batch&eatby=$eatby&sellby=$sellby";
+
+ // Lignes des titres
+ print "";
+ print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder);
+ if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Warehouse"), $_SERVER["PHP_SELF"], "",$param,"",'',$sortfield,$sortorder);
+ //print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Batch"), $_SERVER["PHP_SELF"], "pb.batch",$param,"",'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("l_eatby"), $_SERVER["PHP_SELF"], "pb.eatby",$param,"",'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("l_sellby"), $_SERVER["PHP_SELF"], "pb.sellby",$param,"",'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'align="right"',$sortfield,$sortorder);
+ // TODO Add info of running suppliers/customers orders
+ //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder);
+ print ' ';
+ print_liste_field_titre($langs->trans("Sell"),$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Buy"),$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder);
+ print " \n";
+
+ // Lignes des champs de filtre
+ print '';
+ print '';
+ print ' ';
+ print ' ';
+ print '';
+ print ' ';
+ print ' ';
+ if (! empty($conf->service->enabled) && $type == 1)
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+
+ $product_static=new Product($db);
+ $warehousetmp=new Entrepot($db);
+
+ $var=True;
+ while ($i < min($num,$limit))
+ {
+ $objp = $db->fetch_object($resql);
+
+ // Multilangs
+ if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
+ {
+ $sql = "SELECT label";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_lang";
+ $sql.= " WHERE fk_product=".$objp->rowid;
+ $sql.= " AND lang='". $langs->getDefaultLang() ."'";
+ $sql.= " LIMIT 1";
+
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $objtp = $db->fetch_object($result);
+ if (! empty($objtp->label)) $objp->label = $objtp->label;
+ }
+ }
+
+ $var=!$var;
+ print '';
+ $product_static->ref=$objp->ref;
+ $product_static->id=$objp->rowid;
+ $product_static->label = $objp->label;
+ $product_static->type=$objp->fk_product_type;
+ print $product_static->getNomUrl(1,'',16);
+ //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow"));
+ print ' ';
+ print ''.$objp->label.' ';
+
+ if (! empty($conf->service->enabled) && $type == 1)
+ {
+ print '';
+ if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear");
+ elseif (preg_match('/([0-9]+)m/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth");
+ elseif (preg_match('/([0-9]+)d/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay");
+ else print $objp->duration;
+ print ' ';
+ }
+ //print ''.$objp->stock_theorique.' ';
+ //print ''.$objp->seuil_stock_alerte.' ';
+ //print ''.$objp->desiredstock.' ';
+
+ // Warehouse
+ print '';
+ $warehousetmp->fetch($obj->fk_entrepot);
+ print $warehousetmp->getNomUrl(1);
+ print ' ';
+ print ''.$objp->batch.' ';
+ print ''.dol_print_date($db->jdate($objp->eatby), 'day').' ';
+ print ''.dol_print_date($db->jdate($objp->sellby), 'day').' ';
+ print '';
+ //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' ';
+ print $objp->stock_physique;
+ print ' ';
+ print ''.$langs->trans("Movements").' ';
+ print ''.$product_static->LibStatut($objp->statut,5,0).' ';
+ print ''.$product_static->LibStatut($objp->tobuy,5,1).' ';
+ print " \n";
+ $i++;
+ }
+
+ print "
";
+ print ' ';
+
+ if ($num > $conf->liste_limit)
+ {
+ if ($sref || $snom || $sall || GETPOST('search'))
+ {
+ print_barre_liste('', $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, '');
+ }
+ else
+ {
+ print_barre_liste('', $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":"")."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, '');
+ }
+ }
+
+ $db->free($resql);
+
+}
+else
+{
+ dol_print_error($db);
+}
+
+
+llxFooter();
+$db->close();
diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php
index 788068ea5ec..ce161a1af60 100644
--- a/htdocs/product/stats/card.php
+++ b/htdocs/product/stats/card.php
@@ -67,7 +67,7 @@ if (! empty($id) || ! empty($ref))
if ($result)
{
- $head=product_prepare_head($object, $user);
+ $head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==Product::TYPE_SERVICE?'service':'product');
diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php
index 81b251d795b..7dcf6139534 100644
--- a/htdocs/product/stats/commande.php
+++ b/htdocs/product/stats/commande.php
@@ -89,7 +89,7 @@ if ($id > 0 || ! empty($ref))
if ($result > 0)
{
- $head=product_prepare_head($product, $user);
+ $head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto);
diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php
index f0444356bcc..e6ced5ad905 100644
--- a/htdocs/product/stats/commande_fournisseur.php
+++ b/htdocs/product/stats/commande_fournisseur.php
@@ -96,7 +96,7 @@ if ($id > 0 || ! empty($ref)) {
llxHeader("", "", $langs->trans("CardProduct" . $product->type));
if ($result > 0) {
- $head = product_prepare_head($product, $user);
+ $head = product_prepare_head($product);
$titre = $langs->trans("CardProduct" . $product->type);
$picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto);
diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php
index aa535f02575..d098ca3399b 100644
--- a/htdocs/product/stats/contrat.php
+++ b/htdocs/product/stats/contrat.php
@@ -79,7 +79,7 @@ if ($id > 0 || ! empty($ref))
if ($result > 0)
{
- $head=product_prepare_head($product,$user);
+ $head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto);
diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php
index c0fa1481269..1f4e9b985e5 100644
--- a/htdocs/product/stats/facture.php
+++ b/htdocs/product/stats/facture.php
@@ -90,7 +90,7 @@ if ($id > 0 || ! empty($ref))
if ($result > 0)
{
- $head=product_prepare_head($product, $user);
+ $head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto);
@@ -148,7 +148,7 @@ if ($id > 0 || ! empty($ref))
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql.= " ORDER BY $sortfield $sortorder ";
-
+
//Calcul total qty and amount for global if full scan list
$total_ht=0;
$total_qty=0;
@@ -163,21 +163,21 @@ if ($id > 0 || ! empty($ref))
}
}
}
-
+
$sql.= $db->plimit($conf->liste_limit +1, $offset);
$result = $db->query($sql);
- if ($result)
+ if ($result)
{
$num = $db->num_rows($result);
-
+
if (! empty($id))
$option .= '&id='.$product->id;
if (! empty($search_month))
$option .= '&search_month='.$search_month;
if (! empty($search_year))
$option .= '&search_year='.$search_year;
-
+
print '' . "\n";
if (! empty($sortfield))
print ' ';
@@ -187,7 +187,7 @@ if ($id > 0 || ! empty($ref))
print ' ';
$option .= '&page=' . $page;
}
-
+
print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&id=".$product->id,$sortfield,$sortorder,'',$num,$totalrecords,'');
print '';
print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - ';
@@ -235,7 +235,7 @@ if ($id > 0 || ! empty($ref))
print '
'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).' ';
print " \n";
$i++;
-
+
if (!empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht+=$objp->total_ht;
$total_qty+=$objp->qty;
diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php
index 275a2ff8604..debb0698c44 100644
--- a/htdocs/product/stats/facture_fournisseur.php
+++ b/htdocs/product/stats/facture_fournisseur.php
@@ -82,52 +82,52 @@ if ($id > 0 || ! empty($ref))
{
$product = new Product($db);
$result = $product->fetch($id, $ref);
-
+
$parameters = array('id' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
+
llxHeader("", "", $langs->trans("CardProduct" . $product->type));
-
+
if ($result > 0)
{
- $head = product_prepare_head($product, $user);
+ $head = product_prepare_head($product);
$titre = $langs->trans("CardProduct" . $product->type);
$picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto);
-
+
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
+
print '';
-
+
// Reference
print '';
print '' . $langs->trans("Ref") . ' ';
print $form->showrefnav($product, 'ref', '', 1, 'ref');
print ' ';
print ' ';
-
+
// Libelle
print '' . $langs->trans("Label") . ' ' . $product->libelle . ' ';
print ' ';
-
+
// Status (to sell)
print '' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ') ';
print $product->getLibStatut(2, 0);
print ' ';
-
+
// Status (to buy)
print '' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ') ';
print $product->getLibStatut(2, 1);
print ' ';
-
+
show_stats_for_company($product, $socid);
-
+
print "
";
-
+
print '';
-
+
if ($user->rights->fournisseur->facture->lire)
{
$sql = "SELECT distinct s.nom as name, s.rowid as socid, s.code_client, f.ref, d.total_ht as total_ht,";
@@ -142,14 +142,14 @@ if ($id > 0 || ! empty($ref))
$sql .= " AND f.entity = " . $conf->entity;
$sql .= " AND d.fk_facture_fourn = f.rowid";
$sql .= " AND d.fk_product =" . $product->id;
- if (! empty($search_month))
+ if (! empty($search_month))
$sql .= ' AND MONTH(f.datef) IN (' . $search_month . ')';
- if (! empty($search_year))
+ if (! empty($search_year))
$sql .= ' AND YEAR(f.datef) IN (' . $search_year . ')';
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
if ($socid) $sql .= " AND f.fk_soc = " . $socid;
$sql .= " ORDER BY $sortfield $sortorder ";
-
+
// Calcul total qty and amount for global if full scan list
$total_ht = 0;
$total_qty = 0;
@@ -164,21 +164,21 @@ if ($id > 0 || ! empty($ref))
}
}
}
-
+
$sql .= $db->plimit($conf->liste_limit + 1, $offset);
-
+
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
-
+
if (! empty($id))
$option .= '&id=' . $product->id;
if (! empty($search_month))
$option .= '&search_month=' . $search_month;
if (! empty($search_year))
$option .= '&search_year=' . $search_year;
-
+
print '' . "\n";
if (! empty($sortfield))
print ' ';
@@ -199,7 +199,7 @@ if ($id > 0 || ! empty($ref))
print ' ';
print '';
print '';
-
+
$i = 0;
print '';
print '';
@@ -211,7 +211,7 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre($langs->trans("AmountHT"), $_SERVER["PHP_SELF"], "f.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
print " \n";
-
+
if ($num > 0)
{
$var = True;
@@ -219,7 +219,7 @@ if ($id > 0 || ! empty($ref))
{
$objp = $db->fetch_object($result);
$var = ! $var;
-
+
print '';
print '';
$supplierinvoicestatic->id = $objp->facid;
@@ -236,7 +236,7 @@ if ($id > 0 || ! empty($ref))
print ' ' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . ' ';
print " \n";
$i ++;
-
+
if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht += $objp->total_ht;
$total_qty += $objp->qty;
diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php
index 4eae4c238e1..1776ba571e0 100644
--- a/htdocs/product/stats/propal.php
+++ b/htdocs/product/stats/propal.php
@@ -80,52 +80,52 @@ if ($id > 0 || ! empty($ref))
{
$product = new Product($db);
$result = $product->fetch($id, $ref);
-
+
$parameters = array ('id' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
+
llxHeader("", "", $langs->trans("CardProduct" . $product->type));
-
+
if ($result > 0)
{
- $head = product_prepare_head($product, $user);
+ $head = product_prepare_head($product);
$titre = $langs->trans("CardProduct" . $product->type);
$picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
dol_fiche_head($head, 'referers', $titre, 0, $picto);
-
+
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
+
print '';
-
+
// Reference
print '';
print '' . $langs->trans("Ref") . ' ';
print $form->showrefnav($product, 'ref', '', 1, 'ref');
print ' ';
print ' ';
-
+
// Libelle
print '' . $langs->trans("Label") . ' ' . $product->libelle . ' ';
print ' ';
-
+
// Status (to sell)
print '' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ') ';
print $product->getLibStatut(2, 0);
print ' ';
-
+
// Status (to buy)
print '' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ') ';
print $product->getLibStatut(2, 1);
print ' ';
-
+
show_stats_for_company($product, $socid);
-
+
print "
";
-
+
print '';
-
+
if ($user->rights->propale->lire) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,";
$sql .= " p.ref_client,";
@@ -150,7 +150,7 @@ if ($id > 0 || ! empty($ref))
if ($socid)
$sql .= " AND p.fk_soc = " . $socid;
$sql .= " ORDER BY $sortfield $sortorder ";
-
+
// Calcul total qty and amount for global if full scan list
$total_ht = 0;
$total_qty = 0;
@@ -165,21 +165,21 @@ if ($id > 0 || ! empty($ref))
}
}
}
-
+
$sql .= $db->plimit($conf->liste_limit + 1, $offset);
-
+
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
-
+
if (! empty($id))
$option .= '&id=' . $product->id;
if (! empty($search_month))
$option .= '&search_month=' . $search_month;
if (! empty($search_year))
$option .= '&search_year=' . $search_year;
-
+
print '' . "\n";
if (! empty($sortfield))
print ' ';
@@ -189,7 +189,7 @@ if ($id > 0 || ! empty($ref))
print ' ';
$option .= '&page=' . $page;
}
-
+
print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, '');
print '';
print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - ';
@@ -200,7 +200,7 @@ if ($id > 0 || ! empty($ref))
print ' ';
print '
';
print '';
-
+
$i = 0;
print '';
print '';
@@ -211,7 +211,7 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre($langs->trans("AmountHT"), $_SERVER["PHP_SELF"], "p.total", "", $option, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "p.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
print " \n";
-
+
if ($num > 0)
{
$var = True;
@@ -219,7 +219,7 @@ if ($id > 0 || ! empty($ref))
{
$objp = $db->fetch_object($result);
$var = ! $var;
-
+
print '';
print '';
$propalstatic->id=$objp->propalid;
@@ -236,13 +236,13 @@ if ($id > 0 || ! empty($ref))
print ' ' . $propalstatic->LibStatut($objp->statut, 5) . ' ';
print " \n";
$i ++;
-
+
if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$total_ht += $objp->total_ht;
$total_qty += $objp->qty;
}
}
- }
+ }
print '';
print '' . $langs->trans('Total') . ' ';
print ' ';
@@ -251,12 +251,12 @@ if ($id > 0 || ! empty($ref))
print ' ';
print "
";
print ' ';
- print ' ';
+ print ' ';
} else {
dol_print_error($db);
}
$db->free($result);
- }
+ }
}
} else {
dol_print_error();
diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php
index c41fe590d18..2e9fcfab68e 100644
--- a/htdocs/product/stock/class/mouvementstock.class.php
+++ b/htdocs/product/stock/class/mouvementstock.class.php
@@ -67,16 +67,16 @@ class MouvementStock extends CommonObject
* @param date $eatby eat-by date
* @param date $sellby sell-by date
* @param string $batch batch number
- * @param boolean $skip_sellby If set to true, stock mouvement is done without impacting batch record
+ * @param boolean $skip_batch If set to true, stock movement is done without impacting batch record
* @return int <0 if KO, 0 if fk_product is null, >0 if OK
*/
- function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $inventorycode='', $datem='',$eatby='',$sellby='',$batch='',$skip_sellby=false)
+ function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $inventorycode='', $datem='',$eatby='',$sellby='',$batch='',$skip_batch=false)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$error = 0;
- dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode");
+ dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.", eatby=".$eatby.", sellby=".$sellby.", batch=".$batch.", skip_batch=".$skip_batch);
// Clean parameters
if (empty($price)) $price=0;
@@ -84,6 +84,16 @@ class MouvementStock extends CommonObject
// Check parameters
if (empty($fk_product)) return 0;
+ if ($eatby < 0)
+ {
+ $this->errors[]='ErrorBadValueForParameterEatBy';
+ return -1;
+ }
+ if ($sellby < 0)
+ {
+ $this->errors[]='ErrorBadValueForParameterEatBy';
+ return -1;
+ }
// Set properties of movement
$this->product_id = $fk_product;
@@ -91,7 +101,7 @@ class MouvementStock extends CommonObject
$this->qty = $qty;
$this->type = $type;
- $this->db->begin();
+ $mvid = 0;
$product = new Product($this->db);
$result=$product->fetch($fk_product);
@@ -100,19 +110,69 @@ class MouvementStock extends CommonObject
dol_print_error('',"Failed to fetch product");
return -1;
}
+
+ $this->db->begin();
+
$product->load_stock();
// Test if product require batch data. If yes, and there is not, we throw an error.
- if ($product->hasbatch() && ! $skip_sellby)
+ if (! empty($conf->productbatch->enabled) && $product->hasbatch() && ! $skip_batch)
{
- if (empty($batch) && empty($eatby) && empty($sellby))
+ //if (empty($batch) && empty($eatby) && empty($sellby))
+ if (empty($batch))
{
- $this->errors[]="ErrorTryToMakeMoveOnProductRequiringBatchData";
+ $this->errors[]=$langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->name);
dol_syslog("Try to make a movement of a product with status_batch on without any batch data");
$this->db->rollback();
return -2;
}
+
+ // If a serial number is provided, we check that sellby and eatby match already existing serial
+ $sql = "SELECT pb.rowid, pb.batch, pb.eatby, pb.sellby FROM ".MAIN_DB_PREFIX."product_batch as pb, ".MAIN_DB_PREFIX."product_stock as ps";
+ $sql.= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$fk_product." AND pb.batch = '".$this->db->escape($batch)."'";
+ dol_syslog(get_class($this)."::_create scan serial for this product to check if eatby and sellby match", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i=0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ if ($this->db->jdate($obj->eatby) != $eatby)
+ {
+ $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->eatby), $eatby);
+ dol_syslog($langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->eatby), $eatby));
+ $this->db->rollback();
+ return -3;
+ }
+ if ($this->db->jdate($obj->sellby) != $sellby)
+ {
+ $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->sellby), $sellby);
+ dol_syslog($langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, $this->db->jdate($obj->sellby), $sellby));
+ $this->db->rollback();
+ return -3;
+ }
+ $i++;
+ }
+ }
+ else
+ {
+ dol_print_error($this->db);
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
+ // TODO Check qty is ok for stock move.
+ if (! empty($conf->productbatch->enabled) && $product->hasbatch() && ! $skip_batch)
+ {
+
+ }
+ else
+ {
+
}
// Define if we must make the stock change (If product type is a service or if stock is used also for services)
@@ -129,8 +189,6 @@ class MouvementStock extends CommonObject
$fk_origin = 0;
}
- $mvid = 0;
-
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement(";
$sql.= " datem, fk_product, batch, eatby, sellby,";
$sql.= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype";
@@ -157,7 +215,7 @@ class MouvementStock extends CommonObject
}
else
{
- $this->error=$this->db->lasterror();
+ $this->errors[]=$this->db->lasterror();
$error = -1;
}
@@ -190,7 +248,7 @@ class MouvementStock extends CommonObject
}
else
{
- $this->error=$this->db->lasterror();
+ $this->errors[]=$this->db->lasterror();
$error = -2;
}
}
@@ -212,7 +270,7 @@ class MouvementStock extends CommonObject
$resql=$this->db->query($sql);
if (! $resql)
{
- $this->error=$this->db->lasterror();
+ $this->errors[]=$this->db->lasterror();
$error = -4;
}
*/
@@ -266,7 +324,7 @@ class MouvementStock extends CommonObject
$resql=$this->db->query($sql);
if (! $resql)
{
- $this->error=$this->db->lasterror();
+ $this->errors[]=$this->db->lasterror();
$error = -3;
}
else if(empty($fk_product_stock))
@@ -276,8 +334,8 @@ class MouvementStock extends CommonObject
}
- // Update detail stock for sell-by date
- if (($product->hasbatch()) && (! $error) && (! $skip_sellby))
+ // Update detail stock for batch product
+ if (! $error && ! empty($conf->productbatch->enabled) && $product->hasbatch() && ! $skip_batch)
{
$param_batch=array('fk_product_stock' =>$fk_product_stock, 'eatby'=>$eatby, 'sellby'=>$sellby, 'batchnumber'=>$batch);
$result=$this->_create_batch($param_batch, $qty);
@@ -296,7 +354,7 @@ class MouvementStock extends CommonObject
$resql=$this->db->query($sql);
if (! $resql)
{
- $this->error=$this->db->lasterror();
+ $this->errors[]=$this->db->lasterror();
$error = -4;
}
}
diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php
index dc394f898dc..aacdedc3668 100644
--- a/htdocs/product/stock/index.php
+++ b/htdocs/product/stock/index.php
@@ -27,6 +27,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$langs->load("stocks");
+$langs->load("productbatch");
// Security check
$result=restrictedArea($user,'stock');
@@ -112,7 +113,7 @@ print '';
$max=10;
$sql = "SELECT p.rowid, p.label as produit,";
$sql.= " e.label as stock, e.rowid as entrepot_id,";
-$sql.= " m.value, m.datem";
+$sql.= " m.value as qty, m.datem, m.batch, m.eatby, m.sellby";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m";
$sql.= ", ".MAIN_DB_PREFIX."product as p";
@@ -133,6 +134,12 @@ if ($resql)
print "
";
print ''.$langs->trans("LastMovements",min($num,$max)).' ';
print ''.$langs->trans("Product").' ';
+ if (! empty($conf->productbatch->enabled))
+ {
+ print ''.$langs->trans("Batch").' ';
+ print ''.$langs->trans("l_eatby").' ';
+ print ''.$langs->trans("l_sellby").' ';
+ }
print ''.$langs->trans("Warehouse").' ';
print ''.$langs->trans("FullList").' ';
print " \n";
@@ -148,12 +155,18 @@ if ($resql)
print "
rowid\">";
print img_object($langs->trans("ShowProduct"),"product").' '.$objp->produit;
print " \n";
+ if (! empty($conf->productbatch->enabled))
+ {
+ print '
'.$objp->batch.' ';
+ print '
'.dol_print_date($db->jdate($objp->eatby),'day').' ';
+ print '
'.dol_print_date($db->jdate($objp->sellby),'day').' ';
+ }
print '
';
print img_object($langs->trans("ShowWarehouse"),"stock").' '.$objp->stock;
print " \n";
print '
';
- if ($objp->value > 0) print '+';
- print $objp->value.' ';
+ if ($objp->qty > 0) print '+';
+ print $objp->qty.'';
print "\n";
$i++;
}
diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php
index f6417b389e1..fcc7412c061 100644
--- a/htdocs/product/stock/list.php
+++ b/htdocs/product/stock/list.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2014 Laurent Destailleur
+ * Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2014 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -51,6 +51,8 @@ $year = strftime("%Y",time());
* View
*/
+$form=new Form($db);
+
$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,";
$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
@@ -118,7 +120,11 @@ if ($result)
// Selling value
print '';
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($objp->sellvalue,'MT'),1);
- else print $langs->trans("Variable");
+ else
+ {
+ $htmltext=$langs->trans("OptionMULTIPRICESIsOn");
+ print $form->textwithtooltip($langs->trans("Variable"),$htmltext);
+ }
print ' ';
// Status
print ''.$entrepot->LibStatut($objp->statut,5).' ';
@@ -134,7 +140,14 @@ if ($result)
print '';
print ''.$langs->trans("Total").' ';
print ''.price(price2num($total,'MT'),1,$langs,0,0,-1,$conf->currency).' ';
- print ''.price(price2num($totalsell,'MT'),1,$langs,0,0,-1,$conf->currency).' ';
+ print '';
+ if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell,'MT'),1,$langs,0,0,-1,$conf->currency);
+ else
+ {
+ $htmltext=$langs->trans("OptionMULTIPRICESIsOn");
+ print $form->textwithtooltip($langs->trans("Variable"),$htmltext);
+ }
+ print ' ';
print ' ';
print " \n";
}
diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php
index 8a0b7297e2f..7b3d41c9911 100644
--- a/htdocs/product/stock/massstockmove.php
+++ b/htdocs/product/stock/massstockmove.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2014 Regis Houssin
+/* Copyright (C) 2013-2015 Laurent Destaileur
+ * Copyright (C) 2014 Regis Houssin
*
* 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
@@ -47,6 +47,7 @@ $action = GETPOST('action','alpha');
$id_product = GETPOST('productid', 'int');
$id_sw = GETPOST('id_sw', 'int');
$id_tw = GETPOST('id_tw', 'int');
+$batch = GETPOST('batch');
$qty = GETPOST('qty');
$idline = GETPOST('idline');
@@ -79,11 +80,6 @@ if ($action == 'addline')
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Product")),'errors');
}
- if (! $qty)
- {
- $error++;
- setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")),'errors');
- }
if (! ($id_sw > 0))
{
$error++;
@@ -100,12 +96,47 @@ if ($action == 'addline')
$langs->load("errors");
setEventMessage($langs->trans("ErrorWarehouseMustDiffers"),'errors');
}
+ if (! $qty)
+ {
+ $error++;
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")),'errors');
+ }
+
+ // Check a batch number is provided if product need it
+ if (! $error)
+ {
+ $producttmp=new Product($db);
+ $producttmp->fetch($id_product);
+ if ($producttmp->hasbatch())
+ {
+ if (empty($batch))
+ {
+ $error++;
+ setEventMessage($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData"), 'errors');
+ }
+ }
+ }
+
+ // TODO Check qty is ok for stock move. Note qty may not be enough yet, but we make a check now to report a warning.
+ // What is important is to have qty when doing action 'createmovements'
+ if (! $error)
+ {
+ // Warning, don't forget lines already added into the $_SESSION['massstockmove']
+ if ($producttmp->hasbatch())
+ {
+
+ }
+ else
+ {
+
+ }
+ }
if (! $error)
{
if (count(array_keys($listofdata)) > 0) $id=max(array_keys($listofdata)) + 1;
else $id=1;
- $listofdata[$id]=array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw);
+ $listofdata[$id]=array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch);
$_SESSION['massstockmove']=json_encode($listofdata);
unset($id_product);
@@ -145,6 +176,9 @@ if ($action == 'createmovements')
$id_sw=$val['id_sw'];
$id_tw=$val['id_tw'];
$qty=price2num($val['qty']);
+ $batch=$val['batch'];
+ $dlc=-1; // They are loaded later from serial
+ $dluo=-1; // They are loaded later from serial
if (! $error && $id_sw <> $id_tw && is_numeric($qty) && $id_product)
{
@@ -154,39 +188,98 @@ if ($action == 'createmovements')
// Define value of products moved
$pricesrc=0;
- if (isset($product->stock_warehouse[$id_sw]->pmp)) $pricesrc=$product->stock_warehouse[$id_sw]->pmp;
+ if (! empty($product->pmp)) $pricesrc=$product->pmp;
$pricedest=$pricesrc;
//print 'price src='.$pricesrc.', price dest='.$pricedest;exit;
- // Remove stock
- $result1=$product->correct_stock(
- $user,
- $id_sw,
- $qty,
- 1,
- GETPOST("label"),
- $pricesrc
- );
- if ($result1 < 0)
+ if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) // If product does not need lot/serial
{
- $error++;
- setEventMessage($product->errors,'errors');
- }
+ // Remove stock
+ $result1=$product->correct_stock(
+ $user,
+ $id_sw,
+ $qty,
+ 1,
+ GETPOST("label"),
+ $pricesrc,
+ GETPOST("codemove")
+ );
+ if ($result1 < 0)
+ {
+ $error++;
+ setEventMessage($product->errors,'errors');
+ }
- // Add stock
- $result2=$product->correct_stock(
- $user,
- $id_tw,
- $qty,
- 0,
- GETPOST("label"),
- $pricedest
- );
- if ($result2 < 0)
+ // Add stock
+ $result2=$product->correct_stock(
+ $user,
+ $id_tw,
+ $qty,
+ 0,
+ GETPOST("label"),
+ $pricedest,
+ GETPOST("codemove")
+ );
+ if ($result2 < 0)
+ {
+ $error++;
+ setEventMessage($product->errors,'errors');
+ }
+ }
+ else
{
- $error++;
- setEventMessage($product->errors,'errors');
+ $arraybatchinfo=$product->loadBatchInfo($batch);
+ if (count($arraybatchinfo) > 0)
+ {
+ $firstrecord = array_shift($arraybatchinfo);
+ $dlc=$firstrecord['eatby'];
+ $dluo=$firstrecord['sellby'];
+ //var_dump($batch); var_dump($arraybatchinfo); var_dump($firstrecord); var_dump($dlc); var_dump($dluo); exit;
+ }
+ else
+ {
+ $dlc='';
+ $dluo='';
+ }
+
+ // Remove stock
+ $result1=$product->correct_stock_batch(
+ $user,
+ $id_sw,
+ $qty,
+ 1,
+ GETPOST("label"),
+ $pricesrc,
+ $dlc,
+ $dluo,
+ $batch,
+ GETPOST("codemove")
+ );
+ if ($result1 < 0)
+ {
+ $error++;
+ setEventMessage($product->errors,'errors');
+ }
+
+ // Add stock
+ $result2=$product->correct_stock_batch(
+ $user,
+ $id_tw,
+ $qty,
+ 0,
+ GETPOST("label"),
+ $pricedest,
+ $dlc,
+ $dluo,
+ $batch,
+ GETPOST("codemove")
+ );
+ if ($result2 < 0)
+ {
+ $error++;
+ setEventMessage($product->errors,'errors');
+ }
}
}
else
@@ -254,6 +347,10 @@ $param='';
print '';
print getTitleFieldOfList($langs->trans('ProductRef'),0,$_SERVER["PHP_SELF"],'',$param,'','class="tagtd"',$sortfield,$sortorder);
+if ($conf->productbatch->enabled)
+{
+ print getTitleFieldOfList($langs->trans('Batch'),0,$_SERVER["PHP_SELF"],'',$param,'','class="tagtd"',$sortfield,$sortorder);
+}
print getTitleFieldOfList($langs->trans('WarehouseSource'),0,$_SERVER["PHP_SELF"],'',$param,'','class="tagtd"',$sortfield,$sortorder);
print getTitleFieldOfList($langs->trans('WarehouseTarget'),0,$_SERVER["PHP_SELF"],'',$param,'','class="tagtd"',$sortfield,$sortorder);
print getTitleFieldOfList($langs->trans('Qty'),0,$_SERVER["PHP_SELF"],'',$param,'','align="center" class="tagtd"',$sortfield,$sortorder);
@@ -276,6 +373,13 @@ else
}
print $form->select_produits($id_product,'productid',$filtertype,$limit);
print '';
+// Batch number
+if ($conf->productbatch->enabled)
+{
+ print '';
+ print ' ';
+ print ' ';
+}
// In warehouse
print '';
print $formproduct->selectWarehouses($id_sw,'id_sw','',1);
@@ -301,13 +405,16 @@ foreach($listofdata as $key => $val)
$warehousestatict->fetch($val['id_tw']);
print ' ';
- print ''.$productstatic->getNomUrl(1).' ';
print '';
- $oldref=$productstatic->ref;
- $productstatic->ref=$productstatic->label;
print $productstatic->getNomUrl(1);
- $productstatic->ref=$oldref;
+ print ' - '.$productstatic->label;
print ' ';
+ if ($conf->productbatch->enabled)
+ {
+ print '';
+ print $val['batch'];
+ print ' ';
+ }
print '';
print $warehousestatics->getNomUrl(1);
print ' ';
@@ -333,9 +440,16 @@ print ' ';
print ' ';
// Button to record mass movement
+$codemove=GETPOST('codemove');
$labelmovement=GETPOST("label")?GETPOST('label'):$langs->trans("StockTransfer").' '.dol_print_date($now,'%Y-%m-%d %H:%M');
print '';
+ print '';
+ print ''.$langs->trans("InventoryCode").' ';
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
print '';
print ''.$langs->trans("LabelMovement").' ';
print '';
diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php
index 44cf9df493f..a27713d8b0f 100644
--- a/htdocs/product/stock/mouvement.php
+++ b/htdocs/product/stock/mouvement.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2014 Regis Houssin
+ * Copyright (C) 2015 Juanjo Menent
*
* 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
@@ -52,6 +53,7 @@ $search_product = trim(GETPOST("search_product"));
$search_warehouse = trim(GETPOST("search_warehouse"));
$search_inventorycode = trim(GETPOST("search_inventorycode"));
$search_user = trim(GETPOST("search_user"));
+$search_batch = trim(GETPOST("search_batch"));
$page = GETPOST("page",'int');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@@ -70,6 +72,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$search_product="";
$search_warehouse="";
$search_user="";
+ $search_batch="";
$sall="";
}
@@ -147,34 +150,17 @@ else if ($year > 0)
{
$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
-if (! empty($search_movement))
-{
- $sql.= " AND m.label LIKE '%".$db->escape($search_movement)."%'";
-}
-if (! empty($search_inventorycode))
-{
- $sql.= " AND m.inventorycode LIKE '%".$db->escape($search_inventorycode)."%'";
-}
-if (! empty($search_product_ref))
-{
- $sql.= " AND p.ref LIKE '%".$db->escape($search_product_ref)."%'";
-}
-if (! empty($search_product))
-{
- $sql.= " AND p.label LIKE '%".$db->escape($search_product)."%'";
-}
-if (! empty($search_warehouse))
-{
- $sql.= " AND e.label LIKE '%".$db->escape($search_warehouse)."%'";
-}
-if (! empty($search_user))
-{
- $sql.= " AND u.login LIKE '%".$db->escape($search_user)."%'";
-}
if ($idproduct > 0)
{
$sql.= " AND p.rowid = '".$idproduct."'";
}
+if (! empty($search_movement)) $sql.= " AND m.label LIKE '%".$db->escape($search_movement)."%'";
+if (! empty($search_inventorycode)) $sql.= " AND m.inventorycode LIKE '%".$db->escape($search_inventorycode)."%'";
+if (! empty($search_product_ref)) $sql.= " AND p.ref LIKE '%".$db->escape($search_product_ref)."%'";
+if (! empty($search_product)) $sql.= " AND p.label LIKE '%".$db->escape($search_product)."%'";
+if (! empty($search_warehouse)) $sql.= " AND e.label LIKE '%".$db->escape($search_warehouse)."%'";
+if (! empty($search_user)) $sql.= " AND u.login LIKE '%".$db->escape($search_user)."%'";
+if (! empty($search_batch)) $sql.= " AND m.batch LIKE '%".$db->escape($search_batch)."%'";
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset);
@@ -400,7 +386,7 @@ if ($resql)
{
print "\n";
- if ($user->rights->stock->creer)
+ if ($user->rights->stock->mouvement->creer)
{
print '
'.$langs->trans("StockCorrection").' ';
}
@@ -439,13 +425,13 @@ if ($resql)
if (! empty($conf->productbatch->enabled))
{
$langs->load("productbatch");
- print '
'.$langs->trans("batch_number").' ';
- print '
'.$langs->trans("l_eatby").' ';
- print '
'.$langs->trans("l_sellby").' ';
+ print_liste_field_titre($langs->trans("BatchNumberShort"),$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("l_eatby"),$_SERVER["PHP_SELF"],'m.eatby','',$param,'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("l_sellby"),$_SERVER["PHP_SELF"],'m.sellby','',$param,'align="center"',$sortfield,$sortorder);
}
print_liste_field_titre($langs->trans("Warehouse"),$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible
print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("InventoryCode"),$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("InventoryCodeShort"),$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LabelMovement"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Units"),$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder);
@@ -473,13 +459,13 @@ if ($resql)
// Batch
if (! empty($conf->productbatch->enabled))
{
- print '
';
+ print '
';
print '
';
print '
';
}
// Warehouse
print '
';
- print ' ';
+ print ' ';
print ' ';
// Author
print '
';
@@ -491,7 +477,7 @@ if ($resql)
print ' ';
// Label of movement
print '
';
- print ' ';
+ print ' ';
print ' ';
// Origin of movement
print '
';
@@ -543,7 +529,7 @@ if ($resql)
// Batch
if (! empty($conf->productbatch->enabled))
{
- print ' '.$objp->batch.' ';
+ print '
'.$objp->batch.' ';
print '
'. dol_print_date($objp->eatby,'day') .' ';
print '
'. dol_print_date($objp->sellby,'day') .' ';
}
diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php
index d4a190a482a..40d9ef7e060 100644
--- a/htdocs/product/stock/product.php
+++ b/htdocs/product/stock/product.php
@@ -5,7 +5,7 @@
* Copyright (C) 2005 Simon TOSSER
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2013 Cédric Salvador
- * Copyright (C) 2013 Juanjo Menent
+ * Copyright (C) 2013-2015 Juanjo Menent
* Copyright (C) 2014-2015 Cédric Gross
* Copyright (C) 2015 Marcos García
*
@@ -384,7 +384,7 @@ if ($id > 0 || $ref)
if ($result > 0)
{
- $head=product_prepare_head($product, $user);
+ $head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'stock', $titre, 0, $picto);
@@ -432,7 +432,9 @@ if ($id > 0 || $ref)
// PMP
print ''.$langs->trans("AverageUnitPricePMP").' ';
- print ''.price($product->pmp).' '.$langs->trans("HT").' ';
+ print '';
+ if ($product->pmp > 0) print price($product->pmp).' '.$langs->trans("HT");
+ print ' ';
print ' ';
// Minimum Price
@@ -803,7 +805,7 @@ if (empty($action) && $product->id)
{
print "\n";
- if ($user->rights->stock->creer)
+ if ($user->rights->stock->mouvement->creer)
{
print '
id.'&action=correction">'.$langs->trans("StockCorrection").' ';
}
@@ -821,8 +823,9 @@ if (empty($action) && $product->id)
/*
- * Stock detail
+ * Stock detail (by warehouse). Do not go down into batch.
*/
+
print '
';
print ''.$langs->trans("Warehouse").' ';
print ''.$langs->trans("NumberOfUnit").' ';
@@ -870,9 +873,9 @@ if ($resql)
print ''.$entrepotstatic->getNomUrl(1).' ';
print ''.$obj->reel.($obj->reel<0?' '.img_warning():'').' ';
// PMP
- print ''.(price2num($product->pmp)?price2num($product->pmp,'MU'):'').' '; // Ditto : Show PMP from movement or from product
+ print ''.(price2num($product->pmp)?price2num($product->pmp,'MU'):'').' ';
// Value purchase
- print ''.(price2num($product->pmp)?price(price2num($product->pmp*$obj->reel,'MT')):'').' '; // Ditto : Show PMP from movement or from product
+ print ''.(price2num($product->pmp)?price(price2num($product->pmp*$obj->reel,'MT')):'').' ';
// Sell price
print '';
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price,'MU'),1);
@@ -880,13 +883,13 @@ if ($resql)
print ' ';
// Value sell
print '';
- if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price*$obj->reel,'MT'),1).' '; // Ditto : Show PMP from movement or from product
+ if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price*$obj->reel,'MT'),1).'';
else print $langs->trans("Variable");
print ' '; ;
$total += $obj->reel;
if (price2num($product->pmp)) $totalwithpmp += $obj->reel;
- $totalvalue = $totalvalue + ($product->pmp*$obj->reel); // Ditto : Show PMP from movement or from product
- $totalvaluesell = $totalvaluesell + ($product->price*$obj->reel); // Ditto : Show PMP from movement or from product
+ $totalvalue = $totalvalue + ($product->pmp*$obj->reel);
+ $totalvaluesell = $totalvaluesell + ($product->price*$obj->reel);
//Batch Detail
if ((! empty($conf->productbatch->enabled)) && $product->hasbatch())
{
diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php
index 289c3c31457..0f935c0154c 100644
--- a/htdocs/product/stock/replenish.php
+++ b/htdocs/product/stock/replenish.php
@@ -536,9 +536,11 @@ while ($i < ($limit ? min($num, $limit) : $num))
//virtual stock to compute the stock to buy value
$stocktobuy = max(max($objp->desiredstock, $objp->alertstock) - $stock - $ordered, 0);
$disabled = '';
- if($ordered > 0) {
- $compare = $usevirtualstock ? $stock : $stock + $ordered;
- if($compare >= $objp->desiredstock) {
+ if ($ordered > 0)
+ {
+ $stockforcompare = $usevirtualstock ? $stock : $stock + $ordered;
+ if ($stockforcompare >= $objp->desiredstock)
+ {
$picto = img_picto('', './img/yes', '', 1);
$disabled = 'disabled="disabled"';
}
@@ -546,7 +548,8 @@ while ($i < ($limit ? min($num, $limit) : $num))
$picto = img_picto('', './img/no', '', 1);
}
} else {
- $picto = img_picto('', './img/no', '', 1);
+ //$picto = img_help('',$langs->trans("NoPendingReceptionOnSupplierOrder"));
+ $picto = img_picto($langs->trans("NoPendingReceptionOnSupplierOrder"), './img/no', '', 1);
}
print '';
diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php
index 6f5cb7ae578..871ec4d30f1 100644
--- a/htdocs/product/stock/valo.php
+++ b/htdocs/product/stock/valo.php
@@ -31,7 +31,7 @@ $langs->load("stocks");
// Security check
$result=restrictedArea($user,'stock');
-$sref=GETPOST("sref");;
+$sref=GETPOST("sref");
$snom=GETPOST("snom");
$sall=GETPOST("sall");
diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php
index 480f739285d..413cb589dff 100644
--- a/htdocs/product/traduction.php
+++ b/htdocs/product/traduction.php
@@ -143,7 +143,7 @@ $cancel != $langs->trans("Cancel") &&
$product->fetch($id);
$langtodelete=GETPOST('langdel','alpha');
-
+
if ( $product->delMultiLangs($langtodelete) > 0 )
{
$action = '';
@@ -168,7 +168,7 @@ llxHeader("","",$langs->trans("Translation"));
$form = new Form($db);
$formadmin=new FormAdmin($db);
-$head=product_prepare_head($product, $user);
+$head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'translation', $titre, 0, $picto);
diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php
index 9c55874a762..1df9359dfa5 100644
--- a/htdocs/projet/activity/perday.php
+++ b/htdocs/projet/activity/perday.php
@@ -48,11 +48,33 @@ $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $projectid);
+$now=dol_now();
+$nowtmp=dol_getdate($now);
+$nowday=$nowtmp['mday'];
+$nowmonth=$nowtmp['mon'];
+$nowyear=$nowtmp['year'];
+
+$year=GETPOST('reyear')?GETPOST('reyear'):(GETPOST("year","int")?GETPOST("year","int"):date("Y"));
+$month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("month","int"):date("m"));
+$day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d"));
+$day = (int) $day;
+$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
+
+$daytoparse = $now;
+if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day, $year);
+
/*
* Actions
*/
+if (GETPOST('submitdateselect'))
+{
+ $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
+
+ $action = '';
+}
+
if ($action == 'addtime' && $user->rights->projet->creer)
{
$task = new Task($db);
@@ -133,6 +155,16 @@ $projectstatic=new Project($db);
$project = new Project($db);
$taskstatic = new Task($db);
+$prev = dol_getdate($daytoparse - (24 * 3600));
+$prev_year = $prev['year'];
+$prev_month = $prev['mon'];
+$prev_day = $prev['mday'];
+
+$next = dol_getdate($daytoparse + (24 * 3600));
+$next_year = $next['year'];
+$next_month = $next['mon'];
+$next_day = $next['mday'];
+
$title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent");
@@ -160,7 +192,18 @@ llxHeader("",$title,"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
-print 'id.'">';
+// Show navigation bar
+$nav ="".img_previous($langs->trans("Previous"))." \n";
+$nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,$day,$year),"day")." \n";
+$nav.="".img_next($langs->trans("Next"))." \n";
+$nav.=" (".$langs->trans("Today")." )";
+$nav.=' '.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' ';
+$nav.=' ';
+
+$picto='calendarweek';
+
+
+print ' id > 0 ? '?id='.$project->id : '').'">';
print ' ';
print ' ';
print ' ';
@@ -169,13 +212,15 @@ $head=project_timesheet_prepare_head($mode);
dol_fiche_head($head, 'inputperday', '', 0, 'task');
// Show description of content
-if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').' ';
+if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').' ';
else
{
- if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').' ';
- else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').' ';
+ if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').' ';
+ else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').' ';
}
-
+print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").' ';
+print ' ';
+print "\n";
// Filter on user
/* dol_fiche_head('');
@@ -197,6 +242,10 @@ else
dol_fiche_end();
*/
+
+print ''.$nav.'
';
+
+
print '';
print '';
print ''.$langs->trans("Project").' ';
@@ -207,7 +256,7 @@ print ''.$langs->trans("ProgressDeclared").' ';
print ''.$langs->trans("TimeSpent").' ';
if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").' ';
else print ''.$langs->trans("TimeSpentByUser").' ';
-print ''.$langs->trans("DateAndHour").' ';
+print ''.$langs->trans("HourStart").' ';
print ''.$langs->trans("Duration").' ';
print " \n";
@@ -217,7 +266,7 @@ $restricteditformytask=(empty($conf->global->PROJECT_TIME_ON_ALL_TASKS_MY_PROJEC
if (count($tasksarray) > 0)
{
$j=0;
- projectLinesPerDay($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask);
+ projectLinesPerDay($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $daytoparse);
}
else
{
@@ -234,6 +283,13 @@ print '';
print '';
+print '';
+
+
llxFooter();
$db->close();
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index b7ab0a8bd71..77b65a19c6b 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -49,12 +49,15 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $projectid);
$now=dol_now();
-
-$year=GETPOST("year","int")?GETPOST("year","int"):date("Y");
-$month=GETPOST("month","int")?GETPOST("month","int"):date("m");
-$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
-$day=GETPOST("day","int")?GETPOST("day","int"):date("d");
+$nowtmp=dol_getdate($now);
+$nowday=$nowtmp['mday'];
+$nowmonth=$nowtmp['mon'];
+$nowyear=$nowtmp['year'];
+$year=GETPOST('reyear')?GETPOST('reyear'):(GETPOST("year","int")?GETPOST("year","int"):date("Y"));
+$month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("month","int"):date("m"));
+$day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d"));
$day = (int) $day;
+$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$startdayarray=dol_get_first_day_week($day, $month, $year);
@@ -83,6 +86,13 @@ $usertoprocess=$user;
* Actions
*/
+if (GETPOST('submitdateselect'))
+{
+ $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
+
+ $action = '';
+}
+
if ($action == 'addtime' && $user->rights->projet->creer)
{
$task = new Task($db);
@@ -176,16 +186,15 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js'));
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
-$tmpday = $first_day;
-
// Show navigation bar
$nav ="".img_previous($langs->trans("Previous"))." \n";
-$nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week;
-$nav.=" \n";
+$nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week." \n";
$nav.="".img_next($langs->trans("Next"))." \n";
$nav.=" (".$langs->trans("Today")." )";
-$picto='calendarweek';
+$nav.=' '.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' ';
+$nav.=' ';
+$picto='calendarweek';
print '';
print ' ';
@@ -199,12 +208,14 @@ $head=project_timesheet_prepare_head($mode);
dol_fiche_head($head, 'inputperweek', '', 0, 'task');
// Show description of content
-if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').' ';
+if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').' ';
else
{
- if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').' ';
- else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').' ';
+ if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').' ';
+ else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').' ';
}
+print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").' ';
+print ' ';
print "\n";
// Filter on user
@@ -248,6 +259,7 @@ for($i=0;$i<7;$i++)
{
print ''.dol_print_date($startday + ($i * 3600 * 24), '%a').' '.dol_print_date($startday + ($i * 3600 * 24), 'day').' ';
}
+print ' ';
print "\n";
@@ -268,11 +280,12 @@ if (count($tasksarray) > 0)
+
';
}
else
{
- print ''.$langs->trans("NoTasks").' ';
+ print ''.$langs->trans("NoTasks").' ';
}
print "
";
@@ -287,6 +300,7 @@ print '';
print ' '."\n\n";
+
$modeinput='hours';
print '