forked from Wavyzz/dolibarr
New: Selection of project use the new select2 component.
This commit is contained in:
@@ -1894,7 +1894,7 @@ if ($action == 'create')
|
|||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
if ($action == 'classify') {
|
if ($action == 'classify') {
|
||||||
$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0);
|
$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1);
|
||||||
} else {
|
} else {
|
||||||
$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
|
$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1975,7 +1975,7 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
|||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
// print "$object->id, $object->socid, $object->fk_project";
|
// print "$object->id, $object->socid, $object->fk_project";
|
||||||
if ($action == 'classify') {
|
if ($action == 'classify') {
|
||||||
$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0);
|
$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1);
|
||||||
} else {
|
} else {
|
||||||
$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
|
$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -486,11 +486,11 @@ else if ($id)
|
|||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
if ($action == 'classify')
|
if ($action == 'classify')
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid');
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid', 0, 0, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none');
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none', 0, 0);
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@@ -3352,7 +3352,7 @@ if ($action == 'create')
|
|||||||
|
|
||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
if ($action == 'classify') {
|
if ($action == 'classify') {
|
||||||
$form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0);
|
$form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1);
|
||||||
} else {
|
} else {
|
||||||
$form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
|
$form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1192,11 +1192,11 @@ else
|
|||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
if ($action == "classify")
|
if ($action == "classify")
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,"projectid");
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,"projectid", 0, 0, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,"none");
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,"none", 0, 0);
|
||||||
}
|
}
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
@@ -1730,7 +1730,7 @@ else
|
|||||||
if ($user->societe_id == 0)
|
if ($user->societe_id == 0)
|
||||||
{
|
{
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
$parameters=array();
|
$parameters=array();
|
||||||
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
|
||||||
|
|||||||
@@ -1226,12 +1226,13 @@ class Form
|
|||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
// Enhance with select2
|
// Enhance with select2
|
||||||
if ($conf->use_javascript_ajax)
|
$nodatarole='';
|
||||||
|
/*if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||||
$out.= ajax_combobox($htmlname);
|
$out.= ajax_combobox($htmlname);
|
||||||
$nodatarole=' data-role="none"';
|
$nodatarole=' data-role="none"';
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').$nodatarole.'>';
|
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').$nodatarole.'>';
|
||||||
if ($show_empty) $out.= '<option value="-1"'.((empty($selected) || $selected==-1)?' selected="selected"':'').'> </option>'."\n";
|
if ($show_empty) $out.= '<option value="-1"'.((empty($selected) || $selected==-1)?' selected="selected"':'').'> </option>'."\n";
|
||||||
@@ -3147,9 +3148,10 @@ class Form
|
|||||||
* @param string $htmlname Name of select field
|
* @param string $htmlname Name of select field
|
||||||
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
|
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
|
||||||
* @param int $maxlength Max length
|
* @param int $maxlength Max length
|
||||||
|
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function form_project($page, $socid, $selected='', $htmlname='projectid', $discard_closed=0, $maxlength=20)
|
function form_project($page, $socid, $selected='', $htmlname='projectid', $discard_closed=0, $maxlength=20, $forcefocus=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
@@ -3161,12 +3163,13 @@ class Form
|
|||||||
$langs->load("project");
|
$langs->load("project");
|
||||||
if ($htmlname != "none")
|
if ($htmlname != "none")
|
||||||
{
|
{
|
||||||
|
print "\n";
|
||||||
print '<form method="post" action="'.$page.'">';
|
print '<form method="post" action="'.$page.'">';
|
||||||
print '<input type="hidden" name="action" value="classin">';
|
print '<input type="hidden" name="action" value="classin">';
|
||||||
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>';
|
||||||
$formproject->select_projects($socid,$selected,$htmlname,$maxlength,0,1,$discard_closed);
|
$formproject->select_projects($socid,$selected,$htmlname,$maxlength,0,1,$discard_closed, $forcefocus);
|
||||||
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>';
|
||||||
|
|||||||
@@ -52,9 +52,10 @@ class FormProjets
|
|||||||
* @param int $option_only Return only html options lines without the select tag
|
* @param int $option_only Return only html options lines without the select tag
|
||||||
* @param int $show_empty Add an empty line
|
* @param int $show_empty Add an empty line
|
||||||
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
|
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
|
||||||
|
* @param int $forcefocus Force focus on field (works with javascript only)
|
||||||
* @return int Nber of project if OK, <0 if KO
|
* @return int Nber of project if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0)
|
function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0)
|
||||||
{
|
{
|
||||||
global $user,$conf,$langs;
|
global $user,$conf,$langs;
|
||||||
|
|
||||||
@@ -85,8 +86,17 @@ class FormProjets
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
// Use select2 selector
|
||||||
|
$nodatarole='';
|
||||||
|
if (! empty($conf->use_javascript_ajax))
|
||||||
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||||
|
$out.= ajax_combobox($htmlname, '', 0, $forcefocus);
|
||||||
|
$nodatarole=' data-role="none"';
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($option_only)) {
|
if (empty($option_only)) {
|
||||||
$out.= '<select class="flat" name="'.$htmlname.'">';
|
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
|
||||||
}
|
}
|
||||||
if (!empty($show_empty)) {
|
if (!empty($show_empty)) {
|
||||||
$out.= '<option value="0"> </option>';
|
$out.= '<option value="0"> </option>';
|
||||||
@@ -162,14 +172,9 @@ class FormProjets
|
|||||||
if (empty($option_only)) {
|
if (empty($option_only)) {
|
||||||
$out.= '</select>';
|
$out.= '</select>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print $out;
|
print $out;
|
||||||
|
|
||||||
// Use select2 selector
|
|
||||||
if (! empty($conf->use_javascript_ajax))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
return $num;
|
return $num;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,25 +314,28 @@ function ajax_dialog($title,$message,$w=350,$h=150)
|
|||||||
* @param string $htmlname Name of html select field
|
* @param string $htmlname Name of html select field
|
||||||
* @param array $events More events option. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
* @param array $events More events option. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||||
* @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete
|
* @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete
|
||||||
|
* @param int $forcefocus Force focus on field
|
||||||
* @return string Return html string to convert a select field into a combo
|
* @return string Return html string to convert a select field into a combo
|
||||||
*/
|
*/
|
||||||
function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
//if (! empty($conf->browser->phone)) return ''; // combobox disabled for smartphones (does not works)
|
//if (! empty($conf->browser->phone)) return ''; // combobox disabled for smartphones (does not works)
|
||||||
//if (! empty($conf->dol_use_jmobile)) return ''; // select2 works with jmobile
|
//if (! empty($conf->dol_use_jmobile)) return ''; // select2 works with jmobile
|
||||||
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
||||||
if (empty($conf->use_javascript_ajax)) return '';
|
if (empty($conf->use_javascript_ajax)) return '';
|
||||||
|
|
||||||
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
|
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
|
||||||
|
|
||||||
$msg = '<script type="text/javascript">
|
$msg = '<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(\'#'.$htmlname.'\').select2({
|
$(\'#'.$htmlname.'\').select2({
|
||||||
width: \'resolve\',
|
width: \'resolve\',
|
||||||
minimumInputLength: '.$minLengthToAutocomplete.',
|
minimumInputLength: '.$minLengthToAutocomplete.',
|
||||||
});';
|
})';
|
||||||
|
if ($forcefocus) $msg.= '.select2(\'focus\')';
|
||||||
|
$msg.= ';';
|
||||||
|
|
||||||
if (count($event))
|
if (count($event))
|
||||||
{
|
{
|
||||||
@@ -345,7 +348,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function runJsCodeForEvent'.$htmlname.'(obj) {
|
function runJsCodeForEvent'.$htmlname.'(obj) {
|
||||||
var id = $("#'.$htmlname.'").val();
|
var id = $("#'.$htmlname.'").val();
|
||||||
var method = obj.method;
|
var method = obj.method;
|
||||||
@@ -383,7 +386,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
|||||||
);
|
);
|
||||||
}';
|
}';
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg.= '});'."\n";
|
$msg.= '});'."\n";
|
||||||
$msg.= "</script>\n";
|
$msg.= "</script>\n";
|
||||||
|
|
||||||
|
|||||||
@@ -337,11 +337,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '</td><td colspan="2">';
|
print '</td><td colspan="2">';
|
||||||
if ($action == 'classify')
|
if ($action == 'classify')
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'projectid');
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'projectid', 0, 0, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'none');
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'none', 0, 0);
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1270,11 +1270,11 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
if ($action == 'classify')
|
if ($action == 'classify')
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid');
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid', 0, 0, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none');
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none', 0, 0);
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@@ -1615,7 +1615,7 @@ elseif (! empty($object->id))
|
|||||||
//print "$object->id, $object->socid, $object->fk_project";
|
//print "$object->id, $object->socid, $object->fk_project";
|
||||||
if ($action == 'classify')
|
if ($action == 'classify')
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1', $object->fk_project, 'projectid', 0, 0);
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1'), $object->fk_project, 'projectid', 0, 0, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ if ($resql)
|
|||||||
|
|
||||||
$userstatic = new User($db);
|
$userstatic = new User($db);
|
||||||
$objectstatic=new CommandeFournisseur($db);
|
$objectstatic=new CommandeFournisseur($db);
|
||||||
|
$projectstatic=new Project($db);
|
||||||
|
|
||||||
while ($i < min($num,$conf->liste_limit))
|
while ($i < min($num,$conf->liste_limit))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1941,7 +1941,7 @@ else
|
|||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
if ($action == 'classify')
|
if ($action == 'classify')
|
||||||
{
|
{
|
||||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1', $object->fk_project, 'projectid', 0, 0);
|
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1'), $object->fk_project, 'projectid', 0, 0, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user