Primer commit del sistema avantika sin cambios
This commit is contained in:
79
ajax/productos-materiales.php
Executable file
79
ajax/productos-materiales.php
Executable file
@@ -0,0 +1,79 @@
|
||||
<?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
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user