コード例 #1
0
ファイル: api_company.php プロジェクト: ars0709/restlog
        $post = $req['contact'];
    } else {
        $contact = '-';
    }
    if (isset($req['fax'])) {
        $post = $req['fax'];
    } else {
        $fax = '-';
    }
    if (isset($req['notes'])) {
        $post = $req['notes'];
    } else {
        $notes = '-';
    }
    $data = array('il_company_acc' => $acc, 'il_company_name' => $name, 'il_company_addr1' => $address1, 'il_company_addr2' => $address2, 'il_company_cityId' => $city, 'il_company_post' => $post, 'il_company_email' => $email, 'il_company_phone' => $phone, 'il_company_contact' => $contact, 'il_company_fax' => $fax, 'il_company_notes' => $notes);
    $db = new dbExists();
    $res = $db->isDataExists("select il_company_acc from il_company where il_company_name='" . $name . "'");
    if ($res > 0) {
        response('Data already exists', 'company', $fa, true);
        return false;
    } else {
        $db = new dbCompany();
        $res = $db->createCompany($data);
        if ($res == 0) {
            response('Failed to Company Data', 'company', $fa, true);
        } elseif ($res == 1) {
            response('Insert Company Success', 'company', $su, false);
        }
    }
    return true;
});
コード例 #2
0
ファイル: api_uom.php プロジェクト: ars0709/restlog
 * params - uom_
 */
$app->post('/uom', 'authenticate', function () use($app) {
    // check for required params
    $requiredfields = array('uom_id', 'uom_desc', 'company_acc');
    $req = $_REQUEST;
    if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
        $app = \Slim\Slim::getInstance();
        parse_str($app->request()->getBody(), $req);
    }
    // validate required fields
    if (!RequiredFields($req, $requiredfields)) {
        return false;
    }
    $data = array('il_uom_id' => $req['uom_id'], 'il_uom_desc' => $req['uom_desc'], 'il_company_acc' => $req['company_acc']);
    $db = new dbExists();
    $res = $db->isDataExists("select il_uom_id from il_uom where il_uom_id='" . ${$req}['uom_id'] . "' and il_company_acc='" . $req['company_acc'] . "'");
    if ($res > 0) {
        response('Data already exists', 'UOM', $fa, true);
        return false;
    } else {
        $db = new dbUom();
        $res = $db->createUOM($data);
        if ($res == 0) {
            response('Failed to insert UOM Data', 'UOM', $fa, true);
        } elseif ($res == 1) {
            response('Insert UOM Success', 'UOM', $su, false);
        }
    }
    return true;
});