}
            }
            if ($data["deleted_ranges"] != "") {
                $data["deleted_ranges"] = explode(",", substr($data["deleted_ranges"], 0, -1));
                foreach ($data["deleted_ranges"] as $key => $range_id) {
                    $sql = "DELETE FROM `ranges` WHERE `id`=" . $range_id;
                    $this->_db->query($sql);
                }
            }
        } catch (Exception $e) {
            return false;
        }
        return true;
    }
}
$dm = new DeliveryMethods();
if (isset($_POST["save"])) {
    $data = $dm->cleanPostData($_POST);
    if ($dm->isValid($data)) {
        if ($dm->save($data)) {
            echo json_encode(array("success" => true));
        } else {
            echo json_encode(array("error" => "Something wrong"));
        }
    } else {
        echo json_encode(array("error_form" => $dm->returnErrorForm()));
    }
    die;
}
$deliveryMethods = $dm->fetchDeliveryMethods();
//print_R($deliveryMethods);
예제 #2
0
function save_form()
{
    error_reporting(E_ERROR);
    if (!ini_get('display_errors')) {
        ini_set('display_errors', 1);
    }
    if (isset($_POST['formdata']) && !empty($_POST['formdata'])) {
        $data = json_decode($_POST['formdata'], true);
    }
    $dm = new DeliveryMethods();
    if ($dm->validate($data)) {
        $dm->save_data($data);
        $json = array('success' => 1);
        echo json_encode($json);
    } else {
        $json = array('success' => 0);
        echo json_encode($json);
    }
}
예제 #3
0
파일: index.php 프로젝트: savicmi/tasks
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" src="js/custom.js"></script>
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
        <link rel="stylesheet" type="text/css" href="css/style.css">
    </head>
    <body>

        <!-- Form section -->
        <section>
            <div class="container">
                <div class="row">
                    <div class="col-md-12">

                        <?php 
// gets methods' content as an associative array
$dm = new DeliveryMethods();
$methods = $dm->get_methods();
// if no result from database
if (empty($methods)) {
    $message = '<div class="col-md-12">
                                                <div class="alert alert-danger message" role="alert">
                                                    No methods in the database.
                                                </div>
                                            </div>';
    echo $message;
} else {
    ?>

                                    <form class="form-horizontal col-md-12" id="deliveries">

                                    <?php