Fix: for multi-company
Conflicts: htdocs/comm/propal/class/propal.class.php htdocs/core/class/html.form.class.php
This commit is contained in:
parent
793f4961f6
commit
e5c0a99584
@ -126,15 +126,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Suppression de la propale
|
// Suppression de la propale
|
||||||
else if ($action == 'confirm_delete' && $confirm == 'yes')
|
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propale->supprimer)
|
||||||
{
|
|
||||||
if ($user->rights->propale->supprimer)
|
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$result=$object->delete($user);
|
$result=$object->delete($user);
|
||||||
$id = 0;
|
|
||||||
$brouillon = 1;
|
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
Header('Location: '.$_SERVER["PHP_SELF"]);
|
||||||
@ -147,7 +142,6 @@ else if ($action == 'confirm_delete' && $confirm == 'yes')
|
|||||||
else $mesg='<div class="error">'.$object->error.'</div>';
|
else $mesg='<div class="error">'.$object->error.'</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Remove line
|
// Remove line
|
||||||
else if ($action == 'confirm_deleteline' && $confirm == 'yes')
|
else if ($action == 'confirm_deleteline' && $confirm == 'yes')
|
||||||
|
|||||||
@ -1534,13 +1534,13 @@ abstract class CommonObject
|
|||||||
$sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')";
|
$sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')";
|
||||||
$sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')";
|
$sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')";
|
||||||
}
|
}
|
||||||
//print $sql;
|
print $sql;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetchObjectLink sql=".$sql);
|
dol_syslog(get_class($this)."::fetchObjectLink sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql); echo 'num='.$num.'<br>';
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
@ -1549,13 +1549,14 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
$this->linkedObjectsIds[$obj->targettype][]=$obj->fk_target;
|
$this->linkedObjectsIds[$obj->targettype][]=$obj->fk_target;
|
||||||
}
|
}
|
||||||
|
echo 'fk_target='.$obj->fk_target.' targetid='.$targetid.'<br>';
|
||||||
if ($obj->fk_target == $targetid)
|
if ($obj->fk_target == $targetid)
|
||||||
{
|
{
|
||||||
$this->linkedObjectsIds[$obj->sourcetype][]=$obj->fk_source;
|
$this->linkedObjectsIds[$obj->sourcetype][]=$obj->fk_source;
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
var_dump($this->linkedObjectsIds);
|
||||||
if (! empty($this->linkedObjectsIds))
|
if (! empty($this->linkedObjectsIds))
|
||||||
{
|
{
|
||||||
foreach($this->linkedObjectsIds as $objecttype => $objectids)
|
foreach($this->linkedObjectsIds as $objecttype => $objectids)
|
||||||
@ -1685,8 +1686,10 @@ abstract class CommonObject
|
|||||||
function deleteObjectLinked()
|
function deleteObjectLinked()
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
||||||
$sql.= " WHERE fk_target = ".$this->id;
|
$sql.= " WHERE";
|
||||||
$sql.= " AND targettype = '".$this->element."'";
|
$sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->element."')";
|
||||||
|
$sql.= " OR";
|
||||||
|
$sql.= " (fk_target = ".$this->id." AND targettype = '".$this->element."')";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG);
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
|
|||||||
@ -235,7 +235,13 @@ class Conf
|
|||||||
$rootfordata = DOL_DATA_ROOT;
|
$rootfordata = DOL_DATA_ROOT;
|
||||||
$rootforuser = DOL_DATA_ROOT;
|
$rootforuser = DOL_DATA_ROOT;
|
||||||
// If multicompany module is enabled, we redefine the root of data
|
// If multicompany module is enabled, we redefine the root of data
|
||||||
if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1) $rootfordata.='/'.$this->entity;
|
if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1)
|
||||||
|
{
|
||||||
|
$rootfordata.='/'.$this->entity;
|
||||||
|
var_dump($mc->sharings);
|
||||||
|
//var_dump($mc->referent);
|
||||||
|
var_dump($mc->entities);
|
||||||
|
}
|
||||||
|
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
// TODO Replace this->xxx->enabled by this->modulename->enabled to remove this code
|
// TODO Replace this->xxx->enabled by this->modulename->enabled to remove this code
|
||||||
|
|||||||
@ -35,8 +35,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to manage generation of HTML components
|
* \class Form
|
||||||
* Only common components must be here.
|
* \brief Class to manage generation of HTML components
|
||||||
|
* \remarks Only common components must be here.
|
||||||
*/
|
*/
|
||||||
class Form
|
class Form
|
||||||
{
|
{
|
||||||
@ -118,10 +119,9 @@ class Form
|
|||||||
* @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...)
|
* @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...)
|
||||||
* @param string $editvalue When in edit mode, use this value as $value instead of value
|
* @param string $editvalue When in edit mode, use this value as $value instead of value
|
||||||
* @param object $extObject External object
|
* @param object $extObject External object
|
||||||
* @param string $success Success message
|
|
||||||
* @return string HTML edit field
|
* @return string HTML edit field
|
||||||
*/
|
*/
|
||||||
function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=null,$success=null)
|
function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=false)
|
||||||
{
|
{
|
||||||
global $conf,$langs,$db;
|
global $conf,$langs,$db;
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class Form
|
|||||||
// When option to edit inline is activated
|
// When option to edit inline is activated
|
||||||
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE))
|
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE))
|
||||||
{
|
{
|
||||||
$ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject, $success);
|
$ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -195,10 +195,9 @@ class Form
|
|||||||
* @param int $condition Condition to edit
|
* @param int $condition Condition to edit
|
||||||
* @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx')
|
* @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx')
|
||||||
* @param object $extObject External object
|
* @param object $extObject External object
|
||||||
* @param string $success Success message
|
|
||||||
* @return string HTML edit in place
|
* @return string HTML edit in place
|
||||||
*/
|
*/
|
||||||
private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=null, $success=null)
|
private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=false)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -240,7 +239,7 @@ class Form
|
|||||||
$inputType=$tmp[0]; $inputOption=$tmp[1];
|
$inputType=$tmp[0]; $inputOption=$tmp[1];
|
||||||
if (! empty($tmp[2])) $savemethod=$tmp[2];
|
if (! empty($tmp[2])) $savemethod=$tmp[2];
|
||||||
}
|
}
|
||||||
else if (preg_match('/^datepicker/',$inputType))
|
if (preg_match('/^datepicker/',$inputType))
|
||||||
{
|
{
|
||||||
$tmp=explode(':',$inputType);
|
$tmp=explode(':',$inputType);
|
||||||
$inputType=$tmp[0]; $inputOption=$tmp[1];
|
$inputType=$tmp[0]; $inputOption=$tmp[1];
|
||||||
@ -278,7 +277,6 @@ class Form
|
|||||||
$out.= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n";
|
$out.= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n";
|
||||||
$out.= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
|
$out.= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
|
||||||
$out.= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
|
$out.= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
|
||||||
if (! empty($success)) $out.= '<input id="success_'.$htmlname.'" value="'.$success.'" type="hidden"/>'."\n";
|
|
||||||
//$out.= '<input id="ext_table_element_'.$htmlname.'" value="'.$ext_table_element.'" type="hidden"/>'."\n";
|
//$out.= '<input id="ext_table_element_'.$htmlname.'" value="'.$ext_table_element.'" type="hidden"/>'."\n";
|
||||||
//$out.= '<input id="ext_fk_element_'.$htmlname.'" value="'.$ext_fk_element.'" type="hidden"/>'."\n";
|
//$out.= '<input id="ext_fk_element_'.$htmlname.'" value="'.$ext_fk_element.'" type="hidden"/>'."\n";
|
||||||
|
|
||||||
@ -374,8 +372,7 @@ class Form
|
|||||||
if (empty($conf->use_javascript_ajax))
|
if (empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
if ($type == 'info' || $type == 'help') return $text;
|
if ($type == 'info' || $type == 'help') return $text;
|
||||||
else { $alt=$htmltext; $htmltext='';
|
else { $alt=$htmltext; $htmltext=''; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// If info or help with smartphone, show only text
|
// If info or help with smartphone, show only text
|
||||||
if (! empty($conf->browser->phone))
|
if (! empty($conf->browser->phone))
|
||||||
@ -396,10 +393,9 @@ class Form
|
|||||||
/**
|
/**
|
||||||
* Return combo list of activated countries, into language of user
|
* Return combo list of activated countries, into language of user
|
||||||
*
|
*
|
||||||
* @param string $selected Id or Code or Label of preselected country
|
* @param selected Id or Code or Label of preselected country
|
||||||
* @param string $htmlname Name of html select object
|
* @param htmlname Name of html select object
|
||||||
* @param string $htmloption Options html on select object
|
* @param htmloption Options html on select object
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
function select_pays($selected='',$htmlname='pays_id',$htmloption='')
|
function select_pays($selected='',$htmlname='pays_id',$htmloption='')
|
||||||
{
|
{
|
||||||
@ -409,9 +405,9 @@ class Form
|
|||||||
/**
|
/**
|
||||||
* Return combo list of activated countries, into language of user
|
* Return combo list of activated countries, into language of user
|
||||||
*
|
*
|
||||||
* @param string $selected Id or Code or Label of preselected country
|
* @param selected Id or Code or Label of preselected country
|
||||||
* @param string $htmlname Name of html select object
|
* @param htmlname Name of html select object
|
||||||
* @param string $htmloption Options html on select object
|
* @param htmloption Options html on select object
|
||||||
* @return string HTML string with select
|
* @return string HTML string with select
|
||||||
*/
|
*/
|
||||||
function select_country($selected='',$htmlname='pays_id',$htmloption='')
|
function select_country($selected='',$htmlname='pays_id',$htmloption='')
|
||||||
@ -479,16 +475,121 @@ class Form
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la liste des types de comptes financiers
|
||||||
|
*
|
||||||
|
* @param selected Type pre-selectionne
|
||||||
|
* @param htmlname Nom champ formulaire
|
||||||
|
*/
|
||||||
|
function select_type_comptes_financiers($selected=1,$htmlname='type')
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
$langs->load("banks");
|
||||||
|
|
||||||
|
$type_available=array(0,1,2);
|
||||||
|
|
||||||
|
print '<select class="flat" name="'.$htmlname.'">';
|
||||||
|
$num = count($type_available);
|
||||||
|
$i = 0;
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
if ($selected == $type_available[$i])
|
||||||
|
{
|
||||||
|
print '<option value="'.$type_available[$i].'" selected="selected">'.$langs->trans("BankType".$type_available[$i]).'</option>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<option value="'.$type_available[$i].'">'.$langs->trans("BankType".$type_available[$i]).'</option>';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</select>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of social contributions.
|
||||||
|
* Use mysoc->country_id or mysoc->country_code so they must be defined.
|
||||||
|
*
|
||||||
|
* @param selected Preselected type
|
||||||
|
* @param htmlname Name of field in form
|
||||||
|
* @param useempty Set to 1 if we want an empty value
|
||||||
|
* @param maxlen Max length of text in combo box
|
||||||
|
* @param help Add or not the admin help picto
|
||||||
|
*/
|
||||||
|
function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1)
|
||||||
|
{
|
||||||
|
global $db,$langs,$user,$mysoc;
|
||||||
|
|
||||||
|
if (empty($mysoc->country_id) && empty($mysoc->country_code))
|
||||||
|
{
|
||||||
|
dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($mysoc->country_id))
|
||||||
|
{
|
||||||
|
$sql = "SELECT c.id, c.libelle as type";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
|
||||||
|
$sql.= " WHERE c.active = 1";
|
||||||
|
$sql.= " AND c.fk_pays = ".$mysoc->country_id;
|
||||||
|
$sql.= " ORDER BY c.libelle ASC";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = "SELECT c.id, c.libelle as type";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_pays as p";
|
||||||
|
$sql.= " WHERE c.active = 1 AND c.fk_pays = p.rowid";
|
||||||
|
$sql.= " AND p.code = '".$mysoc->country_code."'";
|
||||||
|
$sql.= " ORDER BY c.libelle ASC";
|
||||||
|
}
|
||||||
|
|
||||||
|
dol_syslog("Form::select_type_socialcontrib sql=".$sql, LOG_DEBUG);
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
print '<select class="flat" name="'.$htmlname.'">';
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
if ($useempty) print '<option value="0"> </option>';
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
print '<option value="'.$obj->id.'"';
|
||||||
|
if ($obj->id == $selected) print ' selected="selected"';
|
||||||
|
print '>'.dol_trunc($obj->type,$maxlen);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
print '</select>';
|
||||||
|
if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db,$db->lasterror());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of types of lines (product or service)
|
* Return list of types of lines (product or service)
|
||||||
* Example: 0=product, 1=service, 9=other (for external module)
|
* Example: 0=product, 1=service, 9=other (for external module)
|
||||||
*
|
*
|
||||||
* @param string $selected Preselected type
|
* @param selected Preselected type
|
||||||
* @param string $htmlname Name of field in html form
|
* @param htmlname Name of field in html form
|
||||||
* @param int $showempty Add an empty field
|
* @param showempty Add an empty field
|
||||||
* @param int $hidetext Do not show label before combo box
|
* @param hidetext Do not show label before combo box
|
||||||
* @param string $forceall Force to show products and services in combo list, whatever are activated modules
|
* @param forceall Force to show products and services in combo list, whatever are activated modules
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
|
function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
|
||||||
{
|
{
|
||||||
@ -612,13 +713,27 @@ class Form
|
|||||||
/**
|
/**
|
||||||
* Output html form to select a third party
|
* Output html form to select a third party
|
||||||
*
|
*
|
||||||
* @param string $selected Preselected type
|
* @param selected Preselected type
|
||||||
* @param string $htmlname Name of field in form
|
* @param htmlname Name of field in form
|
||||||
* @param string $filter Optionnal filters criteras
|
* @param filter Optionnal filters criteras
|
||||||
* @param int $showempty Add an empty field
|
* @param showempty Add an empty field
|
||||||
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
|
* @param showtype Show third party type in combolist (customer, prospect or supplier)
|
||||||
* @param int $forcecombo Force to use combo box
|
* @param forcecombo Force to use combo box
|
||||||
* @return string HTML string with
|
*/
|
||||||
|
function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0)
|
||||||
|
{
|
||||||
|
print $this->select_company($selected,$htmlname,$filter,$showempty,$showtype,$forcecombo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output html form to select a third party
|
||||||
|
*
|
||||||
|
* @param selected Preselected type
|
||||||
|
* @param htmlname Name of field in form
|
||||||
|
* @param filter Optionnal filters criteras
|
||||||
|
* @param showempty Add an empty field
|
||||||
|
* @param showtype Show third party type in combolist (customer, prospect or supplier)
|
||||||
|
* @param forcecombo Force to use combo box
|
||||||
*/
|
*/
|
||||||
function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0)
|
function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0)
|
||||||
{
|
{
|
||||||
@ -635,7 +750,7 @@ class Form
|
|||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
$sql.= " ORDER BY nom ASC";
|
$sql.= " ORDER BY nom ASC";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::select_company sql=".$sql);
|
dol_syslog("Form::select_societes sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -1920,6 +2035,66 @@ class Form
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return combo list of differents status of a proposal
|
||||||
|
* Values are id of table c_propalst
|
||||||
|
*
|
||||||
|
* @param selected etat pre-selectionne
|
||||||
|
* @param short Use short labels
|
||||||
|
*/
|
||||||
|
function select_propal_statut($selected='',$short=0)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
$sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst";
|
||||||
|
$sql .= " WHERE active = 1";
|
||||||
|
|
||||||
|
dol_syslog("Form::select_propal_statut sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
print '<select class="flat" name="propal_statut">';
|
||||||
|
print '<option value=""> </option>';
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
if ($selected == $obj->id)
|
||||||
|
{
|
||||||
|
print '<option value="'.$obj->id.'" selected="selected">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<option value="'.$obj->id.'">';
|
||||||
|
}
|
||||||
|
$key=$obj->code;
|
||||||
|
if ($langs->trans("PropalStatus".$key.($short?'Short':'')) != "PropalStatus".$key.($short?'Short':''))
|
||||||
|
{
|
||||||
|
print $langs->trans("PropalStatus".$key.($short?'Short':''));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Opened','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed');
|
||||||
|
if (! empty($conv_to_new_code[$obj->code])) $key=$conv_to_new_code[$obj->code];
|
||||||
|
print ($langs->trans("PropalStatus".$key.($short?'Short':''))!="PropalStatus".$key.($short?'Short':''))?$langs->trans("PropalStatus".$key.($short?'Short':'')):$obj->label;
|
||||||
|
}
|
||||||
|
print '</option>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</select>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a HTML select list of bank accounts
|
* Return a HTML select list of bank accounts
|
||||||
*
|
*
|
||||||
@ -2337,10 +2512,10 @@ class Form
|
|||||||
/**
|
/**
|
||||||
* Show a form to select a delivery delay
|
* Show a form to select a delivery delay
|
||||||
*
|
*
|
||||||
* @param int $page Page
|
* @param page Page
|
||||||
* @param string $selected Id condition pre-selectionne
|
* @param selected Id condition pre-selectionne
|
||||||
* @param string $htmlname Name of select html field
|
* @param htmlname Name of select html field
|
||||||
* @param int $addempty Ajoute entree vide
|
* @param addempty Ajoute entree vide
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function form_availability($page, $selected='', $htmlname='availability', $addempty=0)
|
function form_availability($page, $selected='', $htmlname='availability', $addempty=0)
|
||||||
@ -2637,11 +2812,11 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output html select to select thirdparty
|
* Affiche formulaire de selection des tiers
|
||||||
*
|
*
|
||||||
* @param string $page Page
|
* @param page Page
|
||||||
* @param string $selected Id preselected
|
* @param selected Id contact pre-selectionne
|
||||||
* @param string $htmlname Name of HTML select
|
* @param htmlname Nom du formulaire select
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function form_thirdparty($page, $selected='', $htmlname='socid')
|
function form_thirdparty($page, $selected='', $htmlname='socid')
|
||||||
@ -2655,7 +2830,7 @@ class Form
|
|||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $this->select_company($selected , $htmlname);
|
$num=$this->select_societes($selected , $htmlname);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||||
print '</tr></table></form>';
|
print '</tr></table></form>';
|
||||||
@ -2668,6 +2843,48 @@ class Form
|
|||||||
$soc = new Societe($this->db);
|
$soc = new Societe($this->db);
|
||||||
$soc->fetch($selected);
|
$soc->fetch($selected);
|
||||||
print $soc->getNomUrl($langs);
|
print $soc->getNomUrl($langs);
|
||||||
|
} else {
|
||||||
|
print " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show form to select addresse
|
||||||
|
*
|
||||||
|
* @param page Page
|
||||||
|
* @param selected Id condition pre-selectionne
|
||||||
|
* @param htmlname Nom du formulaire select
|
||||||
|
* @param origin Origine de l'appel pour pouvoir creer un retour
|
||||||
|
* @param originid Id de l'origine
|
||||||
|
* @return void
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='')
|
||||||
|
{
|
||||||
|
global $langs,$conf;
|
||||||
|
if ($htmlname != "none")
|
||||||
|
{
|
||||||
|
print '<form method="post" action="'.$page.'">';
|
||||||
|
print '<input type="hidden" name="action" value="setaddress">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||||
|
print '<tr><td>';
|
||||||
|
$this->select_address($selected, $socid, $htmlname, 1);
|
||||||
|
print '</td>';
|
||||||
|
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
$langs->load("companies");
|
||||||
|
print ' <a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$socid.'&action=create&origin='.$origin.'&originid='.$originid.'>'.$langs->trans("AddAddress").'</a>';
|
||||||
|
print '</td></tr></table></form>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($selected)
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php");
|
||||||
|
$address=new Address($this->db);
|
||||||
|
$result=$address->fetch_address($selected);
|
||||||
|
print '<a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$address->socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3029,7 +3246,6 @@ class Form
|
|||||||
$base=DOL_URL_ROOT.'/core/';
|
$base=DOL_URL_ROOT.'/core/';
|
||||||
$retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJava").'\',\''.$langs->defaultlang.'\');">'.img_object($langs->trans("SelectDate"),'calendarday','class="datecallink"').'</button>';
|
$retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJava").'\',\''.$langs->defaultlang.'\');">'.img_object($langs->trans("SelectDate"),'calendarday','class="datecallink"').'</button>';
|
||||||
}
|
}
|
||||||
else $retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"),'calendarday','class="datecallink"').'</button>';
|
|
||||||
|
|
||||||
$retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
|
$retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
|
||||||
$retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
|
$retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
|
||||||
@ -3296,9 +3512,7 @@ class Form
|
|||||||
{
|
{
|
||||||
$newval=($translate?$langs->trans($value):$value);
|
$newval=($translate?$langs->trans($value):$value);
|
||||||
$selectOptionValue = dol_htmlentitiesbr($maxlen?dol_trunc($newval,$maxlen):$newval);
|
$selectOptionValue = dol_htmlentitiesbr($maxlen?dol_trunc($newval,$maxlen):$newval);
|
||||||
if ($value == '' || $value == '-') {
|
if ($value == '' || $value == '-') { $selectOptionValue=' '; }
|
||||||
$selectOptionValue=' ';
|
|
||||||
}
|
|
||||||
$out.=$selectOptionValue;
|
$out.=$selectOptionValue;
|
||||||
}
|
}
|
||||||
$out.="</option>\n";
|
$out.="</option>\n";
|
||||||
@ -3414,21 +3628,21 @@ class Form
|
|||||||
* Return a HTML area with the reference of object and a navigation bar for a business object
|
* Return a HTML area with the reference of object and a navigation bar for a business object
|
||||||
* To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria.
|
* To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria.
|
||||||
*
|
*
|
||||||
* @param Object $object Object to show
|
* @param object Object to show
|
||||||
* @param int $paramid Name of parameter to use to name the id into the URL link
|
* @param paramid Name of parameter to use to name the id into the URL link
|
||||||
* @param string $morehtml More html content to output just before the nav bar
|
* @param morehtml More html content to output just before the nav bar
|
||||||
* @param int $shownav Show Condition (navigation is shown if value is 1)
|
* @param shownav Show Condition (navigation is shown if value is 1)
|
||||||
* @param int $fieldid Nom du champ en base a utiliser pour select next et previous
|
* @param fieldid Nom du champ en base a utiliser pour select next et previous
|
||||||
* @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
|
* @param fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
|
||||||
* @param string $morehtmlref Code html supplementaire a afficher apres ref
|
* @param morehtmlref Code html supplementaire a afficher apres ref
|
||||||
* @param string $moreparam More param to add in nav link url.
|
* @param moreparam More param to add in nav link url.
|
||||||
* @return tring Portion HTML avec ref + boutons nav
|
* @return string Portion HTML avec ref + boutons nav
|
||||||
*/
|
*/
|
||||||
function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='')
|
function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='')
|
||||||
{
|
{
|
||||||
$ret='';
|
$ret='';
|
||||||
|
|
||||||
//print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam";
|
//print "$paramid,$morehtml,$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam";
|
||||||
$object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid);
|
$object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid);
|
||||||
$previous_ref = $object->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'">'.img_previous().'</a>':'';
|
$previous_ref = $object->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'">'.img_previous().'</a>':'';
|
||||||
$next_ref = $object->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'">'.img_next().'</a>':'';
|
$next_ref = $object->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'">'.img_next().'</a>':'';
|
||||||
@ -3439,17 +3653,14 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ret.=$object->$fieldref;
|
$ret.=$object->$fieldref;
|
||||||
if ($morehtmlref)
|
if ($morehtmlref) {
|
||||||
{
|
|
||||||
$ret.=' '.$morehtmlref;
|
$ret.=' '.$morehtmlref;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($morehtml)
|
if ($morehtml) {
|
||||||
{
|
|
||||||
$ret.='</td><td class="nobordernopadding" align="right">'.$morehtml;
|
$ret.='</td><td class="nobordernopadding" align="right">'.$morehtml;
|
||||||
}
|
}
|
||||||
if ($shownav && ($previous_ref || $next_ref))
|
if ($shownav && ($previous_ref || $next_ref)) {
|
||||||
{
|
|
||||||
$ret.='</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td>';
|
$ret.='</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td>';
|
||||||
$ret.='<td class="nobordernopadding" align="center" width="20">'.$next_ref;
|
$ret.='<td class="nobordernopadding" align="center" width="20">'.$next_ref;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2009-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -51,11 +51,11 @@ class ProductFournisseur extends Product
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDB $DB Database handler
|
* @param DoliDB $db Database handler
|
||||||
*/
|
*/
|
||||||
function ProductFournisseur($DB)
|
function __construct($db)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -325,14 +325,13 @@ class ProductFournisseur extends Product
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
// Suppliers list
|
|
||||||
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
|
||||||
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn,";
|
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn,";
|
||||||
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability";
|
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql.= " ON pfp.fk_soc = s.rowid";
|
$sql.= " WHERE pfp.entity IN (".getEntity('product', 1).")";
|
||||||
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
$sql.= " AND pfp.fk_soc = s.rowid";
|
||||||
$sql.= " AND pfp.fk_product = ".$prodid;
|
$sql.= " AND pfp.fk_product = ".$prodid;
|
||||||
$sql.= " ORDER BY s.nom, pfp.quantity, pfp.price";
|
$sql.= " ORDER BY s.nom, pfp.quantity, pfp.price";
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,8 @@ $langs->load("bills");
|
|||||||
|
|
||||||
$id = GETPOST('id', 'int');
|
$id = GETPOST('id', 'int');
|
||||||
$ref = GETPOST('ref', 'alpha');
|
$ref = GETPOST('ref', 'alpha');
|
||||||
|
$action = GETPOST('action', 'alpha');
|
||||||
|
$confirm = GETPOST('confirm', 'alpha');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
|
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
|
||||||
@ -52,22 +54,22 @@ $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->ser
|
|||||||
|
|
||||||
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||||
{
|
{
|
||||||
if ($_GET["id"])
|
if ($id)
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result = $product->fetch($_GET["id"]);
|
$result = $product->fetch($id);
|
||||||
|
|
||||||
$result = $product->add_photo($dir, $_FILES['userfile']);
|
$result = $product->add_photo($dir, $_FILES['userfile']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_REQUEST["action"] == 'confirm_delete' && $_GET["file"] && $_REQUEST['confirm'] == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer))
|
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$product->delete_photo($dir."/".$_GET["file"]);
|
$product->delete_photo($dir."/".$_GET["file"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET["action"] == 'addthumb' && $_GET["file"])
|
if ($action == 'addthumb' && $_GET["file"])
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$product->add_thumb($dir."/".$_GET["file"]);
|
$product->add_thumb($dir."/".$_GET["file"]);
|
||||||
@ -80,12 +82,11 @@ if ($_GET["action"] == 'addthumb' && $_GET["file"])
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
if ($_GET["id"] || $_GET["ref"])
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
|
|
||||||
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
$result = $product->fetch($id, $ref);
|
||||||
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
|
||||||
|
|
||||||
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
{
|
{
|
||||||
if (! empty($conf->global->MAIN_UPLOAD_DOC))
|
if (! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/photos.php?action=ajout_photo&id='.$product->id.'">';
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=ajout_photo&id='.$product->id.'">';
|
||||||
print $langs->trans("AddPhoto").'</a>';
|
print $langs->trans("AddPhoto").'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -166,15 +167,15 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
/*
|
/*
|
||||||
* Add a photo
|
* Add a photo
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer) && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
if ($action == 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer) && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||||
{
|
{
|
||||||
// Affiche formulaire upload
|
// Affiche formulaire upload
|
||||||
$formfile=new FormFile($db);
|
$formfile=new FormFile($db);
|
||||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1);
|
$formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$product->id,$langs->trans("AddPhoto"),1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affiche photos
|
// Affiche photos
|
||||||
if ($_GET["action"] != 'ajout_photo')
|
if ($action != 'ajout_photo')
|
||||||
{
|
{
|
||||||
$nbphoto=0;
|
$nbphoto=0;
|
||||||
$nbbyrow=5;
|
$nbbyrow=5;
|
||||||
@ -201,8 +202,7 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter();
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user