Пример #1
0
 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_itemposition($handler_id, array $args, array &$data)
 {
     midcom::get()->skip_page_style = true;
     $item = new org_openpsa_invoices_invoice_item_dba((int) $_POST['id']);
     $item->position = $_POST['position'];
     if (!$item->update()) {
         throw new midcom_error('Failed to update item: ' . midcom_connection::get_error_string());
     }
     return new midcom_response_json(array());
 }
Пример #2
0
    }
}
$qb_items = org_openpsa_invoices_invoice_item_dba::new_query_builder();
$qb_items->add_constraint('task', '>', 0);
$qb_items->add_constraint('deliverable', '=', 0);
$items = $qb_items->execute();
foreach ($items as $item) {
    try {
        $task = new org_openpsa_projects_task_dba($item->task);
    } catch (midcom_error $e) {
        echo 'Failed to load task #' . $item->task . ': ' . $e->getMessage() . ", skipping\n";
        flush();
        continue;
    }
    try {
        $deliverable = new org_openpsa_sales_salesproject_deliverable_dba($task->agreement);
    } catch (midcom_error $e) {
        echo 'Failed to load deliverable #' . $task->agreement . ': ' . $e->getMessage() . ", skipping\n";
        flush();
        continue;
    }
    $item->deliverable = $deliverable->id;
    if ($item->update()) {
        echo 'Updated item #' . $item->id . ' to deliverable ' . $deliverable->title . "\n";
        flush();
    } else {
        echo 'Failed to update item #' . $item->id . ': ' . midcom_connection::get_error_string() . "\n";
        flush();
    }
}
echo "</pre>\n";