diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f283295aeb5..53e78b06f84 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2723,6 +2723,42 @@ class SupplierProposal extends CommonObject return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'socid')) { + $return .= ' | '.$this->socid.''; + } + if (property_exists($this, 'delivery_date')) { + $return .= '
'.$langs->trans("DateEnd").' : '.dol_print_date($this->delivery_date).''; + } + if (property_exists($this, 'total_ttc')) { + $return .='
'.$langs->trans("AmountHT").' : '.price($this->total_ttc).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index add084e91ab..b4426ec84d8 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -57,6 +57,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierproposallist'; +$mode = GETPOST('mode', 'alpha'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); @@ -510,6 +511,9 @@ if ($resql) { } $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -630,7 +634,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', $url, '', $user->rights->supplier_proposal->creer); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', $url, '', $user->rights->supplier_proposal->creer); // Fields title search print '
'; @@ -642,6 +649,7 @@ if ($resql) { print ''; print ''; print ''; + print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_proposal', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -973,288 +981,304 @@ if ($resql) { $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; } - print ''; - } - if (!empty($arrayfields['sp.ref']['checked'])) { - print ''; - - print ''; - // Picto + Ref - print ''; - // Warning - $warnornote = ''; - //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); - if ($warnornote) { - print ''; + } + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } - // Other picto tool - print '
'; - print $objectstatic->getNomUrl(1, '', '', 0, -1, 1); - print ''; - print $warnornote; + // Output Kanban + $userstatic->fetch($obj->fk_user_author); + $objectstatic->socid = $companystatic->getNomUrl(1); + $objectstatic->user_author_id = $userstatic->getNomUrl(1); + $objectstatic->delivery_date = $obj->dp; + print $objectstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - print '
'; + if (!empty($arrayfields['sp.ref']['checked'])) { + print ''; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - print $companystatic->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print $companystatic->name_alias; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - print $obj->town; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - print $obj->zip; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "".$obj->state_name."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date proposal - if (!empty($arrayfields['sp.date_valid']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date delivery - if (!empty($arrayfields['sp.date_livraison']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->dp), 'day'); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT - if (!empty($arrayfields['sp.total_ht']['checked'])) { - print ''.price($obj->total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ht'; - } - $totalarray['val']['sp.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['sp.total_tva']['checked'])) { - print ''.price($obj->total_tva)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva'; - } - $totalarray['val']['sp.total_tva'] += $obj->total_tva; - } - // Amount TTC - if (!empty($arrayfields['sp.total_ttc']['checked'])) { - print ''.price($obj->total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ttc'; - } - $totalarray['val']['sp.total_ttc'] += $obj->total_ttc; - } - - // Currency - if (!empty($arrayfields['sp.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) { - print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) { - print ''.price($obj->multicurrency_total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT - if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) { - print ''.price($obj->multicurrency_total_vat)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC - if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) { - print ''.price($obj->multicurrency_total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->status = $obj->ustatus; - $userstatic->lastname = $obj->name; - $userstatic->firstname = $obj->firstname; - $userstatic->photo = $obj->photo; - $userstatic->admin = $obj->admin; - $userstatic->ref = $obj->fk_user_author; - $userstatic->employee = $obj->employee; - $userstatic->email = $obj->uemail; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print ''; - if ($userstatic->id > 0) { - print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); - } else { - print ' '; - } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['sp.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['sp.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['sp.fk_statut']['checked'])) { - print ''.$objectstatic->getLibStatut(5)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + print ''; + // Picto + Ref + print ''; + // Warning + $warnornote = ''; + //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); + if ($warnornote) { + print ''; + } + // Other picto tool + print '
'; + print $objectstatic->getNomUrl(1, '', '', 0, -1, 1); + print ''; + print $warnornote; + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print '
'; + + print "\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; + + // Thirdparty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + print $companystatic->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print $companystatic->name_alias; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + print $obj->town; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + print $obj->zip; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "".$obj->state_name."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (empty($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date proposal + if (!empty($arrayfields['sp.date_valid']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_valid), 'day'); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date delivery + if (!empty($arrayfields['sp.date_livraison']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->dp), 'day'); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Amount HT + if (!empty($arrayfields['sp.total_ht']['checked'])) { + print ''.price($obj->total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ht'; + } + $totalarray['val']['sp.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['sp.total_tva']['checked'])) { + print ''.price($obj->total_tva)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_tva'; + } + $totalarray['val']['sp.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['sp.total_ttc']['checked'])) { + print ''.price($obj->total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'sp.total_ttc'; + } + $totalarray['val']['sp.total_ttc'] += $obj->total_ttc; + } + + // Currency + if (!empty($arrayfields['sp.multicurrency_code']['checked'])) { + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) { + print ''; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) { + print ''.price($obj->multicurrency_total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) { + print ''.price($obj->multicurrency_total_vat)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) { + print ''.price($obj->multicurrency_total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->status = $obj->ustatus; + $userstatic->lastname = $obj->name; + $userstatic->firstname = $obj->firstname; + $userstatic->photo = $obj->photo; + $userstatic->admin = $obj->admin; + $userstatic->ref = $obj->fk_user_author; + $userstatic->employee = $obj->employee; + $userstatic->email = $obj->uemail; + + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if ($userstatic->id > 0) { + print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); + } else { + print ' '; + } + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['sp.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['sp.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['sp.fk_statut']['checked'])) { + print ''.$objectstatic->getLibStatut(5)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; } - if (!$i) { - $totalarray['nbfield']++; - } - - print "\n"; - - $total += $obj->total_ht; - $subtotal += $obj->total_ht; - $i++; }