Example #1
0
             $branch = new Branch($_POST['key']);
             $branch->delete();
         } catch (fExpectedException $e) {
             echo $e->printMessage();
         }
     } else {
         if ($_POST['type'] == "add") {
             try {
                 $branch = new Branch();
                 $branch->populate();
                 $branch->store();
                 $theId = $branch->getId();
                 $ids = Inv_item::findIdUB($db);
                 foreach ($ids as $id) {
                     $stock = new Inv_stock();
                     $stock->setBranchId($theId);
                     $stock->setItemId($id);
                     $stock->setQuantity(0);
                     $stock->store();
                 }
             } catch (fExpectedException $e) {
                 echo $e->printMessage();
             }
         } else {
             if ($_POST['type'] == "name") {
                 $branch = new Branch($_POST['key']);
                 echo $branch->prepareName();
             }
         }
     }
 }
<?php

include '../resources/init.php';
if (isset($_POST['type'])) {
    if ($_POST['type'] == "add") {
        try {
            $inv_item = new Inv_item();
            $inv_item->populate();
            $inv_item->store();
            $branches = Branch::findAll();
            foreach ($branches as $branch) {
                $stock = new Inv_stock();
                $stock->setBranchId($branch->getId());
                $stock->setItemId($inv_item->getId());
                $stock->setQuantity(0);
                $stock->store();
            }
        } catch (fExpectedException $e) {
            echo $e->printMessage();
        }
    } else {
        if ($_POST['type'] == "delete") {
            try {
                $inv_item = new Inv_item($_POST['key']);
                $inv_item->delete();
            } catch (fExpectedException $e) {
                echo $e->printMessage();
            }
        } else {
            if ($_POST['type'] == "edit") {
                try {