Пример #1
0
function autoupdate_comics(&$tasklist)
{
    $list = glob('comics/*', GLOB_NOSORT | GLOB_ONLYDIR);
    $day_array = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
    foreach ($list as $file) {
        $story = basename($file);
        $ini = parse_ini_file($file . "/metadata.ini");
        if (isset($ini['updates'])) {
            // Add story to appropriate update list
            $func = create_task('update_comic', $story);
            if (strtolower($ini['updates']) == 'daily') {
                foreach ($day_array as $day) {
                    $tasklist['day_of_week'][$day][] = $func;
                }
            } else {
                $days = split(',', $ini['updates']);
                foreach ($days as $day) {
                    $day = ucfirst($day);
                    if (in_array($day, $day_array)) {
                        $tasklist['day_of_week'][$day][] = $func;
                    } else {
                        // Assume it's a numeric date
                        $day = preg_replace("/\\D/", "", $day);
                        $tasklist['date'][$day][] = $func;
                    }
                }
            }
        }
    }
}
Пример #2
0
     echo add_to_project($_POST);
 } else {
     if (strpos($uri, '/remove_from_project') !== false) {
         echo remove_from_project($_POST);
     } else {
         if (strpos($uri, '/uploadServiceImage') !== false) {
             echo upload_service_image($_POST, $_FILES);
         } else {
             if (strpos($uri, '/upload') !== false) {
                 echo upload_document($_POST, $_FILES);
             } else {
                 if (strpos($uri, '/create_discussion') !== false) {
                     echo create_discussion($_POST);
                 } else {
                     if (strpos($uri, '/create_task') !== false) {
                         echo create_task($_POST);
                     } else {
                         if (strpos($uri, '/product') !== false) {
                             echo get_product($_GET);
                         } else {
                             if (strpos($uri, '/get_product_review') !== false) {
                                 echo get_product_review($_GET);
                             } else {
                                 if (strpos($uri, '/add_product_review') !== false) {
                                     echo add_product_review($_POST);
                                 } else {
                                     if (strpos($uri, '/add_like_dislike') !== false) {
                                         echo add_like_dislike($_POST);
                                     } else {
                                         if (strpos($uri, '/edit_product') !== false) {
                                             echo edit_product($_POST);
Пример #3
0
function onfleet($order_id)
{
    global $woocommerce;
    $order = new WC_Order($order_id);
    $name = get_post_meta($order_id, '_billing_first_name', true) . ' ' . get_post_meta($order_id, '_billing_last_name', true);
    $phone = get_post_meta($order_id, '_billing_phone', true);
    $address = get_post_meta($order_id, '_shipping_address_1', true);
    $number = substr($address, 0, strpos($address, ' '));
    $street = substr($address, strpos($address, ' '));
    $apartment = get_post_meta($order_id, '_shipping_address_2', true);
    $city = get_post_meta($order_id, '_shipping_city', true);
    $medallion = strtoupper(get_user_meta($order->user_id, 'loyalty_status', true));
    $order_amount = get_post_meta($order_id, '_order_total', true);
    if (get_post_meta($order_id, '_payment_method', true) == 'cod') {
        $pay_method = 'Cash on delivery';
    } else {
        $pay_method = 'Credit card on delivery';
    }
    $order_items = $order->get_items();
    foreach ($order_items as $product) {
        $product_meta[] = $product['name'] . ' (' . strtok($product['item_meta']['size'][0], ' ') . ')';
    }
    $product_list = implode("\\n", $product_meta);
    $notes = "Order #{$order_id}\\n\\n" . "{$product_list}\\n" . "{$medallion}\\n\\n" . "Total \${$order_amount}\\n" . "{$pay_method}";
    function create_destination($number, $street, $apartment, $city)
    {
        $json_data = '{"address":{
				"number":"' . $number . '",
				"street":"' . $street . '",
				"apartment":"' . $apartment . '",
				"city":"' . $city . '",
				"state":"CA",
				"country":"USA"
			}}';
        $response = request('https://onfleet.com/api/v2/destinations', 'post', $json_data);
        return $response->id;
    }
    function get_recipient($name)
    {
        $url = 'https://onfleet.com/api/v2/recipients/name/' . rawurlencode($name);
        $response = request($url, 'get');
        if (!$response->id) {
            return 'missing';
        }
        return $response->id;
    }
    function create_recipient($name, $phone)
    {
        $json_data = '{"name":"' . $name . '",
			"phone":"' . $phone . '"}';
        $response = request('https://onfleet.com/api/v2/recipients', 'post', $json_data);
        if (!$response->id) {
            return 'duplicate';
        } else {
            return $response->id;
        }
    }
    function create_task($destination, $recipient, $notes)
    {
        $json_data = '{"merchant":"6FMcvdZ2CkFRb*iE1Zrr*XDQ",
			"executor":"6FMcvdZ2CkFRb*iE1Zrr*XDQ",
			"destination":"' . $destination . '",
			"recipients":["' . $recipient . '"],
			"notes":"' . $notes . '",
			"completeAfter":' . round(microtime(true) * 1000) . '}';
        $response = request('https://onfleet.com/api/v2/tasks', 'post', $json_data);
        return $response;
    }
    $destination = create_destination($number, $street, $apartment, $city);
    $recipient = get_recipient($name);
    if ($recipient == 'missing') {
        $recipient = create_recipient($name, $phone);
    }
    $task = create_task($destination, $recipient, $notes);
    if (!$task->id) {
        return 'error';
    } else {
        $sql = "UPDATE wp_posts SET task_id='{$task->id}' WHERE id={$order_id}";
        wp_db($sql);
    }
}
function create_tasks($user_name, $output_list)
{
    $counter = 0;
    foreach ($output_list as $task) {
        if ($task[date_due] == "4501-01-01") {
            $task[date_due] = "";
        }
        $id = create_task($user_name, $task[start_date], $task[date_modified], $task[name], $task[status], $task[priority], $task[description], $task[date_due], $task[contact_name]);
        $output_list[$counter]['id'] = $id;
        $counter++;
    }
    return array_reverse($output_list);
}
Пример #5
0
    $o = $_GET['o'];
}
if (isset($o)) {
    if ($o == 'delete') {
        delete_project($p);
        success('successfully delete the project');
    }
    if ($o == 'create') {
        if (isset($_POST['name'])) {
            $uid = $_SESSION["user"]["uid"];
            $name = $_POST['name'];
            $priority = $_POST['priority'];
            $start = time_db($_POST['start']);
            $end = time_db($_POST['end']);
            $description = $_POST['description'];
            $tid = create_task($p, $uid, $name, $priority, $start, $end, $description);
            goto_url("task.php?t={$tid}");
        } else {
            error('empty task name');
        }
    }
}
if (fetch_project($p) == FALSE) {
} else {
    //project name, start/end time, page title, page sub title
    $db_array = fetch_project($p);
    $db_array_task = fetch_project_task($p);
    $db_array_task_history = fetch_project_task_history($p);
    $project_name = $db_array[0]['name'];
    $project_start = time_uk($db_array[0]['start']);
    $project_end = time_uk($db_array[0]['end']);