コード例 #1
0
ファイル: Item.class.php プロジェクト: centaurustech/truc
    public function store()
    {
        global $g_pdo;
        $this->id = create_id();
        $created_t = time();
        $mod_t = $created_t;
        $request = <<<EOF
INSERT INTO `item`
SET
\t`id`= :id,
\t`created_t`= :created_t,
\t`mod_t`= :mod_t,
\t`class`= :class,
\t`tax_rate`= :tax_rate,
\t`description`= :description,
\t`quantity`= :quantity,
\t`total_ht`= :total_ht,
\t`total_tax`= :total_tax,
\t`total_ttc`= :total_ttc,
\t`id_bill`= :id_bill
EOF;
        $pst = $g_pdo->prepare($request);
        $array = array(":id" => $this->id, ":created_t" => $created_t, ":mod_t" => $mod_t, ":class" => $this->class, ":tax_rate" => $this->tax_rate, ":description" => $this->description, ":quantity" => $this->quantity, ":total_ht" => $this->total_ht, ":total_tax" => $this->total_tax, ":total_ttc" => $this->total_ttc, ":id_bill" => $this->bill_id);
        $pst->execute($array);
    }
コード例 #2
0
ファイル: Ticket.class.php プロジェクト: centaurustech/truc
    public function store()
    {
        global $g_pdo;
        $this->id = create_id();
        $created_t = time();
        $mod_t = $created_t;
        $request = <<<EOF
INSERT INTO `ticket`
SET
\t`id`= :id,
\t`created_t`= :created_t,
\t`mod_t`= :mod_t,
\t`name`= :name,
\t`type`= :type,
\t`amount`= :amount,
\t`max_quantity`= :max_quantity,
\t`tax_rate`= :tax_rate,
\t`start_t`= :start_t,
\t`end_t`= :end_t,
\t`description`= :description,
\t`id_event`= :event_id
EOF;
        debug($request);
        $pst = $g_pdo->prepare($request);
        $array = array(":id" => $this->id, ":created_t" => $created_t, ":mod_t" => $mod_t, ":name" => $this->name, ":type" => $this->type, ":amount" => $this->amount, ":max_quantity" => $this->max_quantity, ":tax_rate" => $this->tax_rate, ":start_t" => $this->start_t, ":end_t" => $this->end_t, ":description" => $this->description, ":event_id" => $this->event_id);
        $pst->execute($array);
    }
コード例 #3
0
ファイル: test_id.php プロジェクト: s910501/id_server
function bench_test($count)
{
    printf("pid:%d running...\n", getmypid());
    $min_time = 1000000.0;
    $max_time = 1.0E-7;
    $fail = 0;
    $total_time = 1.0E-7;
    for ($i = 0; $i < $count; ++$i) {
        $begin_time = microtime();
        $id = create_id("bench", strval(getmypid()), "xx");
        if (empty($id) || strlen($id) < 1) {
            ++$fail;
        }
        $consume_time = microtime() - $begin_time;
        if ($consume_time > 1.0E-7) {
            if ($min_time > $consume_time) {
                $min_time = $consume_time;
            }
            if ($max_time < $consume_time) {
                $max_time = $consume_time;
            }
            $total_time += $consume_time;
        }
    }
    printf("pid:%d total:%d fail:%d min:%f max:%f avg:%f\n", getmypid(), $count, $fail, $min_time, $max_time, $total_time / $count);
}
コード例 #4
0
ファイル: Address.class.php プロジェクト: centaurustech/truc
    public function store()
    {
        global $g_pdo;
        $this->id = create_id();
        $created_t = time();
        $mod_t = $created_t;
        $request = <<<EOF
INSERT INTO `address`
SET
\t`id`= :id,
\t`address`= :address,
\t`created_t`= :created_t,
\t`mod_t`= :mod_t,
\t`lat`= :lat,
\t`lng`= :lng,
\t`street_number`= :street_number,
\t`route`= :route,
\t`postal_code`= :postal_code,
\t`locality`= :locality,
\t`administrative_area_level_2`= :administrative_area_level_2,
\t`administrative_area_level_1`= :administrative_area_level_1,
\t`country`= :country;
EOF;
        debug($request);
        $pst = $g_pdo->prepare($request);
        $array = array(":id" => $this->id, ":created_t" => $created_t, ":mod_t" => $mod_t, ":address" => $this->address, ":lat" => $this->lat, ":lng" => $this->lng, ":street_number" => $this->street_number, ":route" => $this->route, ":postal_code" => $this->postal_code, ":locality" => $this->locality, ":administrative_area_level_2" => $this->administrative_area_level_2, ":administrative_area_level_1" => $this->administrative_area_level_1, ":country" => $this->country);
        $pst->execute($array);
    }
コード例 #5
0
ファイル: install.php プロジェクト: siwiwit/PhreeBooksERP
function create_id($array)
{
    $securitys = '';
    if (isset($array['submenu'])) {
        foreach ($array['submenu'] as $menu_item) {
            $securitys .= create_id($menu_item);
        }
    } else {
        if (isset($array['security_id'])) {
            $securitys = $array['security_id'] . ':4,';
        }
    }
    return $securitys;
}
コード例 #6
0
ファイル: Bill.class.php プロジェクト: centaurustech/truc
    public function store()
    {
        global $g_pdo;
        if ($this->type == BILL_TYPE_INVOICE) {
            $this->label .= "#" . seq_next('invoice');
        } else {
            $this->label .= "#" . seq_next('quotation');
        }
        $this->id = create_id();
        $this->created_t = time();
        $this->mod_t = $this->created_t;
        $request = <<<EOF
INSERT INTO `bill`
SET
\t`id`= :id,
\t`created_t`= :created_t,
\t`mod_t`= :mod_t,
\t`flags`= :flags,
\t`total_ht`= :total_ht,
\t`total_tax`= :total_tax,
\t`total_ttc`= :total_ttc,
\t`label`= :label,
\t`client_name`= :client_name,
\t`status`= :status,
\t`type`= :type,
\t`id_user`= :id_user,
\t`id_event`= :id_event,
\t`payment_info`= :payment_info,
\t`client_vat`= :client_vat,
\t`biller_name`= :biller_name,
\t`biller_vat`= :biller_vat,
\t`target`= :target,
\t`id_client_address`= :client_address_id,
\t`id_biller_address`= :biller_address_id
EOF;
        $pst = $g_pdo->prepare($request);
        $array = array(":id" => $this->id, ":created_t" => $this->created_t, ":mod_t" => $this->mod_t, ":flags" => $this->flags, ":total_ht" => $this->total_ht, ":total_tax" => $this->total_tax, ":total_ttc" => $this->total_ttc, ":label" => $this->label, ":client_name" => $this->client_name, ":status" => $this->status, ":type" => $this->type, ":id_user" => $this->user_id, ":id_event" => $this->event_id, ":payment_info" => $this->payment_info, ":client_vat" => $this->client_vat, ":biller_name" => $this->biller_name, ":biller_vat" => $this->biller_vat, ":target" => $this->target, ":client_address_id" => $this->client_address_id, ":biller_address_id" => $this->biller_address_id);
        $pst->execute($array);
        $event = Event::get_from_id($this->event_id);
        $event->add_funding_acquired($this->total_ttc);
        foreach ($this->items as $item) {
            $item->bill_id = $this->id;
            $item->store();
        }
    }
コード例 #7
0
 public function send()
 {
     debug("Action Send");
     $this->set_status(ADVERTISEMENT_STATUS_SENT);
     $event = Event::get_from_id($this->get_field("event_id")->value);
     foreach ($event->get_guests() as $guest) {
         $task = new Task();
         $task->hydrate();
         $task->id = create_id();
         $task->set_value("start_t", time());
         $task->set_value("description", "");
         $task->set_value("command", "mail_advertisement");
         $task->set_value("parameters", $event->id . "," . $guest->get_value("email") . "," . $this->id);
         $task->set_value("status", TASK_STATUS_PENDING);
         $task->set_value("error_msg", "");
         $task->set_value("event_id", $_SESSION["event_id"]);
         $task->store();
     }
 }
コード例 #8
0
ファイル: Discount.class.php プロジェクト: centaurustech/truc
    public function store()
    {
        global $g_pdo;
        $this->id = create_id();
        $created_t = time();
        $mod_t = $created_t;
        $request = <<<EOF
INSERT INTO `discount`
SET
\t`id`= :id,
\t`created_t`= :created_t,
\t`mod_t`= :mod_t,
\t`code`= :code,
\t`class`= :class,
\t`expiration_t`= :expiration_t,
\t`amount`= :amount,
\t`percentage`= :percentage,
\t`id_event`= :event_id
EOF;
        debug($request);
        $pst = $g_pdo->prepare($request);
        $array = array(":id" => $this->id, ":created_t" => $created_t, ":mod_t" => $mod_t, ":code" => $this->code, ":class" => $this->class, ":expiration_t" => $this->expiration_t, ":amount" => $this->amount, ":percentage" => $this->percentage, ":event_id" => $this->event_id);
        $pst->execute($array);
    }
コード例 #9
0
ファイル: Event.class.php プロジェクト: centaurustech/truc
    public function store()
    {
        global $g_pdo;
        $this->id = create_id();
        $created_t = time();
        $mod_t = $created_t;
        $publish_flag = EVENT_PUBLISH_FLAG_NO;
        $request = <<<EOF
INSERT INTO `event`
SET
\t`id`= :id,
\t`created_t`= :created_t,
\t`mod_t`= :mod_t,
\t`id_user`= :id_user,
\t`title`= :title,
\t`organizer_name`= :organizer_name,
\t`phone`= :phone,
\t`vat`= :vat,
\t`link`= :link,
\t`short_description`= :short_description,
\t`long_description`= :long_description,
\t`happening_t`= :happening_t,
\t`confirmation_t`= :confirmation_t,
\t`funding_needed`= :funding_needed,
\t`funding_acquired`=0,
\t`type`= :type,
\t`status`= :status,
\t`publish_flag`= :publish_flag,
\t`flags`= :flags,
\t`deal_name`= :deal_name,
\t`id_address`= :location_address_id,
\t`id_address1`= :billing_address_id
EOF;
        debug($request);
        $pst = $g_pdo->prepare($request);
        $array = array(":id" => $this->id, ":created_t" => $created_t, ":mod_t" => $mod_t, ":id_user" => $this->user_id, ":title" => $this->title, ":organizer_name" => $this->organizer_name, ":phone" => $this->phone, ":vat" => $this->vat, ":link" => $this->link, ":short_description" => $this->short_description, ":long_description" => $this->long_description, ":happening_t" => $this->happening_t, ":confirmation_t" => $this->confirmation_t, ":funding_needed" => $this->funding_needed, ":type" => $this->type, ":status" => $this->status, ":publish_flag" => $publish_flag, ":flags" => $this->flags, ":deal_name" => $this->deal_name, ":location_address_id" => $this->location_address_id, ":billing_address_id" => $this->billing_address_id);
        $pst->execute($array);
    }
コード例 #10
0
ファイル: blogcontroller.php プロジェクト: solostyle/iam
 function add()
 {
     $this->doNotRenderHeader = true;
     /* i want this to be an ajax request*/
     $this->set('isAjax', $this->doNotRenderHeader);
     // modifying entry
     if (isset($_POST['id'])) {
         // get the existing one
         $this->Entry->id = $_POST['id'];
         $existing = $this->Entry->search();
         // clears the object
         // save and delete it
         $this->Entry->id = $_POST['id'];
         $this->Entry->category = $existing['Entry']['category'];
         $this->Entry->title = $existing['Entry']['title'];
         $this->Entry->entry = $existing['Entry']['entry'];
         $this->Entry->time = $existing['Entry']['time'];
         $this->Entry->delete();
         // clears the object
         // insert new entry
         $oldIdArray = explode("/", $existing['Entry']['id']);
         $oldYear = $oldIdArray[0];
         $oldMonth = $oldIdArray[1];
         $oldDate = $oldIdArray[2];
         $this->Entry->id = create_id($_POST['title'], $oldYear, $oldMonth, $oldDate);
         $this->Entry->time = $existing['Entry']['time'];
     } else {
         // new entry only
         $this->Entry->id = create_id($_POST['title'], $_POST['year'], $_POST['month'], $_POST['date']);
         $this->Entry->time = $_POST['time'];
     }
     // always insert a new row
     $this->Entry->category = $_POST['category'];
     $this->Entry->title = $_POST['title'];
     $this->Entry->entry = $_POST['entry'];
     $this->Entry->my_save();
     // clears the object
 }
コード例 #11
0
ファイル: Record.class.php プロジェクト: centaurustech/truc
 public static function create()
 {
     debug(sprint_r($_GET));
     try {
         $record = Record::new_instance($_GET["type"]);
         $record->check_form();
         $record->id = create_id();
         $record->hydrate_from_form();
         $record->store();
         message_set_info(_t("Record successfully created."));
     } catch (Exception $e) {
         message_set_error($e->getMessage());
     }
 }
コード例 #12
0
ファイル: test_id.php プロジェクト: shitfSign/id_server
<?php

function create_id($rule_name, $app_name, $salt = '')
{
    $server_list = array("udp://127.0.0.1:1200", "udp://127.0.0.1:1200");
    shuffle($server_list);
    $new_id = "";
    foreach ($server_list as $server_info) {
        $sock = fsockopen($server_info);
        stream_set_timeout($sock, 2, 0);
        fwrite($sock, json_encode(array("action" => "create", "rule_name" => $rule_name, "app_name" => $app_name, "salt" => $salt)));
        $data = fread($sock, 256);
        fclose($sock);
        $result = json_decode($data, true);
        if (is_array($result) && $result["code"] == 0) {
            $new_id = $result["data"];
            break;
        }
    }
    return $new_id;
}
$id = create_id("task", "test", "xx");
echo "{$id} \n";
コード例 #13
0
ファイル: User.class.php プロジェクト: centaurustech/truc
 public static function create_from_partner($email, $lastname, $firstname, $locale)
 {
     $user = new User();
     $user->id = create_id();
     $user->email = $email;
     $user->firstname = $firstname;
     $user->lastname = $lastname;
     $user->password = $_SESSION['partner'];
     $user->locale = $locale;
     $user->add_flag(ROLE_USER);
     $user->activation_status = ACTIVATION_STATUS_ACTIVATED;
     $user->clean_format();
     $address = new Address();
     $address->store();
     $user->address_id = $address->id;
     $user->store();
     message_set_info(_t('An account has been created based on the information given by ' . format_partner($_SESSION['partner'])));
     unset($_SESSION['partner']);
     return $user;
 }