Clean Code
This commit is contained in:
parent
452ec0bdfb
commit
498d56319d
@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php';
|
||||
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("mrp", "other"));
|
||||
@ -89,7 +91,6 @@ $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($
|
||||
$upload_dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -582,47 +583,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '</div>';
|
||||
|
||||
print "</form>\n";
|
||||
?>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
$(document).ready(function() {
|
||||
// When clicking on collapse
|
||||
$(".collapse_bom").click(function() {
|
||||
console.log("We click on collapse");
|
||||
var id_bom_line = $(this).attr('id').replace('collapse-', '');
|
||||
console.log($(this).html().indexOf('folder-open'));
|
||||
if($(this).html().indexOf('folder-open') <= 0) {
|
||||
$('[parentid="'+ id_bom_line +'"]').show();
|
||||
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
|
||||
}
|
||||
else {
|
||||
$('[parentid="'+ id_bom_line +'"]').hide();
|
||||
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// To Show all the sub bom lines
|
||||
$("#show_all").click(function() {
|
||||
console.log("We click on show all");
|
||||
$("[class^=sub_bom_lines]").show();
|
||||
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
|
||||
return false;
|
||||
});
|
||||
|
||||
// To Hide all the sub bom lines
|
||||
$("#hide_all").click(function() {
|
||||
console.log("We click on hide all");
|
||||
$("[class^=sub_bom_lines]").hide();
|
||||
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
print mrpCollapseBomManagement();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -131,3 +131,55 @@ function bomPrepareHead($object)
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage collapse bom display
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function mrpCollapseBomManagement(){
|
||||
?>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
// When clicking on collapse
|
||||
$(".collapse_bom").click(function() {
|
||||
console.log("We click on collapse");
|
||||
var id_bom_line = $(this).attr('id').replace('collapse-', '');
|
||||
console.log($(this).html().indexOf('folder-open'));
|
||||
if($(this).html().indexOf('folder-open') <= 0) {
|
||||
$('[parentid="'+ id_bom_line +'"]').show();
|
||||
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
|
||||
}
|
||||
else {
|
||||
$('[parentid="'+ id_bom_line +'"]').hide();
|
||||
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// To Show all the sub bom lines
|
||||
$("#show_all").click(function() {
|
||||
console.log("We click on show all");
|
||||
$("[class^=sub_bom_lines]").show();
|
||||
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
|
||||
return false;
|
||||
});
|
||||
|
||||
// To Hide all the sub bom lines
|
||||
$("#hide_all").click(function() {
|
||||
console.log("We click on hide all");
|
||||
$("[class^=sub_bom_lines]").hide();
|
||||
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -8442,7 +8442,6 @@ class Form
|
||||
}
|
||||
|
||||
$res = @include dol_buildpath($reldir.'/'.$tplname.'.tpl.php');
|
||||
|
||||
if ($res) {
|
||||
$nboftypesoutput++;
|
||||
break;
|
||||
@ -8504,7 +8503,6 @@ 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').')'),
|
||||
@ -8571,7 +8569,6 @@ class Form
|
||||
$sql = $possiblelink['sql'];
|
||||
|
||||
$resqllist = $this->db->query($sql);
|
||||
|
||||
if ($resqllist) {
|
||||
$num = $this->db->num_rows($resqllist);
|
||||
$i = 0;
|
||||
|
||||
@ -675,7 +675,6 @@ class Mo extends CommonObject
|
||||
}
|
||||
|
||||
$resultline = $moline->create($user, false); // Never use triggers here
|
||||
|
||||
if ($resultline <= 0) {
|
||||
$error++;
|
||||
$this->error = $moline->error;
|
||||
@ -1206,7 +1205,7 @@ class Mo extends CommonObject
|
||||
|
||||
/**
|
||||
* Create an array of lines
|
||||
*
|
||||
* @param string $rolefilter
|
||||
* @return array|int array of lines if OK, <0 if KO
|
||||
*/
|
||||
public function getLinesArray($rolefilter = '')
|
||||
@ -1694,9 +1693,7 @@ class MoLine extends CommonObjectLine
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
|
||||
while ($i < ($limit ? min($limit, $num) : $num)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
|
||||
@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
|
||||
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("mrp", "other"));
|
||||
@ -112,7 +114,6 @@ if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
if (empty($reshook)) {
|
||||
$error = 0;
|
||||
|
||||
@ -130,14 +131,11 @@ if (empty($reshook)) {
|
||||
if ($cancel && !empty($backtopageforcancel)) {
|
||||
$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)) {
|
||||
if ($action == 'add' && empty($id) && !empty($TBomLineId)) {
|
||||
$noback = "";
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||
|
||||
@ -281,48 +279,11 @@ if ($action == 'create') {
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print mrpCollapseBomManagement();
|
||||
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
/*TODO : DUPLICATA, factoriser le code : bom_card.php line 589**/
|
||||
|
||||
// When clicking on collapse
|
||||
$(".collapse_bom").click(function() {
|
||||
console.log("We click on collapse");
|
||||
var id_bom_line = $(this).attr('id').replace('collapse-', '');
|
||||
console.log($(this).html().indexOf('folder-open'));
|
||||
if($(this).html().indexOf('folder-open') <= 0) {
|
||||
$('[parentid="'+ id_bom_line +'"]').show();
|
||||
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
|
||||
}
|
||||
else {
|
||||
$('[parentid="'+ id_bom_line +'"]').hide();
|
||||
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// To Show all the sub bom lines
|
||||
$("#show_all").click(function() {
|
||||
console.log("We click on show all");
|
||||
$("[class^=sub_bom_lines]").show();
|
||||
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
|
||||
return false;
|
||||
});
|
||||
|
||||
// To Hide all the sub bom lines
|
||||
$("#hide_all").click(function() {
|
||||
console.log("We click on hide all");
|
||||
$("[class^=sub_bom_lines]").hide();
|
||||
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
|
||||
return false;
|
||||
});
|
||||
|
||||
/*TODO : DUPLICATA, factoriser le code**/
|
||||
|
||||
jQuery('#fk_bom').change(function() {
|
||||
console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val());
|
||||
if (jQuery('#fk_bom').val() > 0)
|
||||
|
||||
@ -29,7 +29,6 @@ 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'];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user