79 lines
1.8 KiB
PHP
Executable File
79 lines
1.8 KiB
PHP
Executable File
<?php
|
|
|
|
include_once('../init.php');
|
|
include_once('../config.php');
|
|
include_once(DOC_ROOT.'/libraries.php');
|
|
|
|
session_start();
|
|
|
|
switch($_POST["type"]){
|
|
|
|
case 'addMaterial':
|
|
|
|
$prodMats = array();
|
|
|
|
if(count($_POST['materialId']) == 0)
|
|
$_POST['materialId'] = array();
|
|
|
|
foreach($_POST['materialId'] as $k => $materialId){
|
|
$card['materialId'] = $materialId;
|
|
$card['porcentaje'] = $_POST['porcentaje'][$k];
|
|
|
|
$prodMats[$k] = $card;
|
|
}
|
|
|
|
$card['materialId'] = 0;
|
|
$card['porcentaje'] = 0;
|
|
|
|
$prodMats[] = $card;
|
|
|
|
$_SESSION['prodMats'] = $prodMats;
|
|
|
|
echo 'ok[#]';
|
|
|
|
$prodMats = $_SESSION['prodMats'];
|
|
|
|
$materiales = $material->EnumerateAll();
|
|
$materiales = $util->EncodeResult($materiales);
|
|
|
|
$smarty->assign('prodMats', $prodMats);
|
|
$smarty->assign('materiales', $materiales);
|
|
$smarty->assign("DOC_ROOT", DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/productos-materiales.tpl');
|
|
|
|
break;
|
|
|
|
case 'deleteMaterial':
|
|
|
|
$key = $_POST['k'];
|
|
|
|
$prodMats = array();
|
|
|
|
foreach($_POST['materialId'] as $k => $materialId){
|
|
$card['materialId'] = $materialId;
|
|
$card['porcentaje'] = $_POST['porcentaje'][$k];
|
|
|
|
$prodMats[$k] = $card;
|
|
}
|
|
|
|
unset($prodMats[$key]);
|
|
|
|
$_SESSION['prodMats'] = $prodMats;
|
|
|
|
echo 'ok[#]';
|
|
|
|
$prodMats = $_SESSION['prodMats'];
|
|
|
|
$materiales = $material->EnumerateAll();
|
|
$materiales = $util->EncodeResult($materiales);
|
|
|
|
$smarty->assign('prodMats', $prodMats);
|
|
$smarty->assign('materiales', $materiales);
|
|
$smarty->assign("DOC_ROOT", DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/productos-materiales.tpl');
|
|
|
|
break;
|
|
|
|
}//switch
|
|
|
|
?>
|