[eluser]baudday[/eluser]
Code:
function quantities()
{
$total = 0;
if($this->form_validation->run('qty') == FALSE){}
else
{
foreach($_POST['sizes'] as $color=>$swatch)
{
$total = $total + array_sum($swatch);
foreach($swatch as $size=>$qty)
{
$sizes[$color][$size] = $qty;
}
}
unset($qty);
$this->load->model('shirts');
if($total >= 24 && $total <= 47)
{
$mult = $this->shirts->getPricePoints(24);
$qty = 24;
}
else if($total >= 48 && $total <= 71)
{
$mult = $this->shirts->getPricePoints(48);
$qty = 48;
}
else if($total >= 72 && $total <= 2499)
{
$mult = $this->shirts->getPricePoints(72);
$qty = 72;
}
else if($total >= 2500 && $total <= 4999)
{
$mult = $this->shirts->getPricePoints(2500);
$qty = 2500;
}
else if($total >= 5000 && $total <= 9999)
{
$mult = $this->shirts->getPricePoints(5000);
$qty = 5000;
}
else if($total >= 10000)
{
$mult = $this->shirts->getPricePoints(5000);
$qty = 10000;
}
$info = array('total' => $total,
'mult' => $mult,
'sizes' => $sizes,
'qty' => $qty
);
$this->session->set_userdata($info);
$this->load->view('ink');
}
}
function ink()
{
if($_POST['ink'] == 0)
{
$data['error'] = 'You must print at least one color.';
$this->load->view('ink', $data);
}
else
{
$info['pname'] = $_POST['name'];
$info['pnum'] = $_POST['num'];
$inks = $_POST['ink'];
$this->load->model('shirts');
foreach($inks as $key=>$num)
{
if($num != 0)
{
$info['qty'][$key] = $num;
$info['price'][$key] = $this->shirts->getInkPrice($this->session->userdata('qty'), $num);
}
}
$data['inks'] = $info;
$this->session->set_userdata($data);
unset($data);
$this->calculate();
}
}