WIP
This commit is contained in:
parent
27cbd16bb9
commit
0f4b1e1d7a
@ -8406,11 +8406,6 @@ class Form
|
||||
if (empty($conf->expedition->enabled)) {
|
||||
continue; // Do not show if module disabled
|
||||
}
|
||||
} elseif ($objecttype == 'mo') {
|
||||
$tplpath = 'mrp/mo';
|
||||
if (empty($conf->mrp->enabled)) {
|
||||
continue; // Do not show if module disabled
|
||||
}
|
||||
} elseif ($objecttype == 'ficheinter') {
|
||||
$tplpath = 'fichinter';
|
||||
if (empty($conf->ficheinter->enabled)) {
|
||||
@ -8447,6 +8442,7 @@ class Form
|
||||
}
|
||||
|
||||
$res = @include dol_buildpath($reldir.'/'.$tplname.'.tpl.php');
|
||||
|
||||
if ($res) {
|
||||
$nboftypesoutput++;
|
||||
break;
|
||||
@ -8508,6 +8504,7 @@ class Form
|
||||
unset($tmpproject);
|
||||
}
|
||||
|
||||
|
||||
$possiblelinks = array(
|
||||
'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('propal').')'),
|
||||
'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande').')'),
|
||||
@ -8574,6 +8571,7 @@ class Form
|
||||
$sql = $possiblelink['sql'];
|
||||
|
||||
$resqllist = $this->db->query($sql);
|
||||
|
||||
if ($resqllist) {
|
||||
$num = $this->db->num_rows($resqllist);
|
||||
$i = 0;
|
||||
|
||||
@ -107,3 +107,4 @@ THMEstimatedHelp=Ce taux permet de définir un coût prévisionnel de l'article
|
||||
BOM=Nomenclature
|
||||
CollapseBOMHelp=You can define the default display of the details of the nomenclature in the configuration of the BOM module
|
||||
MOAndLines=Ordres de fabrication et lignes
|
||||
MOParent=Ordre de fabrication parent
|
||||
|
||||
@ -1427,6 +1427,79 @@ class Mo extends CommonObject
|
||||
|
||||
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function used to return childs of Mo
|
||||
*
|
||||
* @return array if OK, -1 if KO
|
||||
*/
|
||||
public function getMoChilds(){
|
||||
|
||||
$TMoChilds = array();
|
||||
$error = 0;
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."mrp_mo as mo_child";
|
||||
$sql.= " WHERE fk_parent_line IN ";
|
||||
$sql.= " (SELECT rowid FROM ".MAIN_DB_PREFIX."mrp_production as line_parent";
|
||||
$sql.= " WHERE fk_mo=".((int)$this->id).")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if($resql){
|
||||
if($this->db->num_rows($resql) > 0){
|
||||
while($obj = $this->db->fetch_object($resql)){
|
||||
$MoChild = new Mo($this->db);
|
||||
$res = $MoChild->fetch($obj->rowid);
|
||||
if($res > 0) $TMoChilds[$MoChild->id] = $MoChild;
|
||||
else $error++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if($error){
|
||||
return -1;
|
||||
} else {
|
||||
return $TMoChilds;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to return childs of Mo
|
||||
*
|
||||
* @return object Mo if OK, -1 if KO, 0 if not exist
|
||||
*/
|
||||
public function getMoParent(){
|
||||
|
||||
$MoParent = new Mo($this->db);
|
||||
$error = 0;
|
||||
|
||||
$sql = "SELECT lineparent.fk_mo as id_moparent FROM ".MAIN_DB_PREFIX."mrp_mo as mo";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mrp_production lineparent ON mo.fk_parent_line = lineparent.rowid";
|
||||
$sql.= " WHERE mo.rowid = ".((int)$this->id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if($resql){
|
||||
if($this->db->num_rows($resql) > 0){
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$res = $MoParent->fetch($obj->id_moparent);
|
||||
if($res < 0) $error++;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if($error){
|
||||
return -1;
|
||||
} else {
|
||||
return $MoParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1667,92 +1740,4 @@ class MoLine extends CommonObjectLine
|
||||
return $this->deleteCommon($user, $notrigger);
|
||||
//return $this->deleteCommon($user, $notrigger, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a link to the object card (with optionaly the picto)
|
||||
*
|
||||
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||
* @param string $option On what the link point to ('nolink', '', 'production', ...)
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $morecss Add more css on link
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @return string String with URL
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
|
||||
{
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
}
|
||||
|
||||
$result = '';
|
||||
|
||||
$moparent = new Mo($this->db);
|
||||
$moparent->fetch($this->fk_mo);
|
||||
|
||||
$label = img_picto('', $moparent->picto).' <u class="paddingrightonly">'.$langs->trans("ManufacturingOrder").'</u>';
|
||||
if (isset($moparent->status)) {
|
||||
$label .= ' '.$moparent->getLibStatut(5);
|
||||
}
|
||||
$label .= '<br>';
|
||||
$label .= '<b>'.$langs->trans('Ref').':</b> '.$moparent->ref;
|
||||
if (isset($moparent->label)) {
|
||||
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$moparent->label;
|
||||
}
|
||||
|
||||
$url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$moparent->id;
|
||||
if ($option == 'production') {
|
||||
$url = DOL_URL_ROOT.'/mrp/mo_production.php?id='.$moparent->id;
|
||||
}
|
||||
|
||||
if ($option != 'nolink') {
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
}
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowMo");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
} else {
|
||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart .= $linkclose.'>';
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($moparent->picto ? $moparent->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $moparent->ref;
|
||||
}
|
||||
$result .= $linkend;
|
||||
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
|
||||
|
||||
global $action, $hookmanager;
|
||||
$hookmanager->initHooks(array('modao'));
|
||||
$parameters = array('id'=>$moparent->id, 'getnomurl'=>$result);
|
||||
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $moparent, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook > 0) {
|
||||
$result = $hookmanager->resPrint;
|
||||
} else {
|
||||
$result .= $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,13 +131,12 @@ if (empty($reshook)) {
|
||||
$backtopage = $backtopageforcancel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||
|
||||
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
|
||||
|
||||
if($action == 'add' && empty($id)){
|
||||
|
||||
$noback = "";
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||
|
||||
@ -163,6 +162,7 @@ if (empty($reshook)) {
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||
|
||||
$res = $object->add_object_linked('mo', $mo_parent->id);
|
||||
}
|
||||
|
||||
$noback = 0;
|
||||
@ -174,8 +174,6 @@ if (empty($reshook)) {
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||
|
||||
|
||||
|
||||
// Actions when linking object each other
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
|
||||
|
||||
@ -463,6 +461,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
if ($ref == 'PROV') {
|
||||
$object->fetch_product();
|
||||
$numref = $object->getNextNumRef($object->fk_product);
|
||||
|
||||
} else {
|
||||
$numref = $object->ref;
|
||||
}
|
||||
@ -567,6 +566,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent tableforfield">'."\n";
|
||||
|
||||
//Mo Parent
|
||||
$mo_parent = $object->getMoParent();
|
||||
if(is_object($mo_parent)) {
|
||||
print '<tr class="field_fk_mo_parent">';
|
||||
print '<td class="titlefield fieldname_fk_mo_parent">' . $langs->trans('MOParent') . '</td>';
|
||||
print '<td class="valuefield fieldname_fk_mo_parent">' .$mo_parent->getNomUrl(1).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Common attributes
|
||||
$keyforbreak = 'fk_warehouse';
|
||||
unset($object->fields['fk_project']);
|
||||
@ -765,7 +773,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang);
|
||||
|
||||
// Show links to link elements
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('mo'));
|
||||
$linktoelem = $form->showLinkToObjectBlock($object,'', array('mo'));
|
||||
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||
|
||||
|
||||
|
||||
@ -29,23 +29,27 @@ print "<!-- BEGIN PHP TEMPLATE mrp/tpl/linkedopjectblock.tpl.php -->\n";
|
||||
global $user, $db;
|
||||
global $noMoreLinkedObjectBlockAfter;
|
||||
|
||||
//var_dump($object); exit;
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
$object = $GLOBALS['object'];
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->load("bom");
|
||||
|
||||
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
|
||||
|
||||
$total = 0;
|
||||
$ilink = 0;
|
||||
foreach ($linkedObjectBlock as $key => $objectlink) {
|
||||
|
||||
$mo_static = new Mo($db);
|
||||
$res = $mo_static->fetch($object->id);
|
||||
$TMoChilds = $mo_static->getMoChilds();
|
||||
|
||||
foreach ($TMoChilds as $key => $objectlink) {
|
||||
|
||||
$ilink++;
|
||||
$product_static = new Product($db);
|
||||
|
||||
$trclass = 'oddeven';
|
||||
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
|
||||
$trclass .= ' liste_sub_total';
|
||||
}
|
||||
|
||||
echo '<tr class="'.$trclass.'" >';
|
||||
echo '<td class="linkedcol-element" >'.$langs->trans("ManufacturingOrder");
|
||||
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
|
||||
@ -55,26 +59,14 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
||||
echo '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
|
||||
|
||||
echo '<td class="linkedcol-ref" align="center">';
|
||||
$result = $product_static->fetch($objectlink->fk_product);
|
||||
if ($result < 0) {
|
||||
setEventMessage($product_static->error, 'errors');
|
||||
} elseif ($result > 0) {
|
||||
$product_static->getNomUrl(1);
|
||||
}
|
||||
// $result = $product_static->fetch($objectlink->fk_product);
|
||||
print '</td>';
|
||||
echo '<td class="linkedcol-date" align="center">'.dol_print_date($objectlink->date_creation, 'day').'</td>';
|
||||
echo '<td class="linkedcol-amount right">';
|
||||
if ($user->rights->commande->lire) {
|
||||
$total = $total + $objectlink->total_ht;
|
||||
echo price($objectlink->total_ht);
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td class="linkedcol-amount right">-</td>';
|
||||
echo '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
|
||||
echo '<td class="linkedcol-action right">';
|
||||
// For now, shipments must stay linked to order, so link is not deletable
|
||||
if ($object->element != 'shipping') {
|
||||
echo '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&token='.newToken().'&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a>';
|
||||
}
|
||||
echo '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&token='.newToken().'&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a>';
|
||||
echo '</td>';
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user