-
Notifications
You must be signed in to change notification settings - Fork 26
/
Sales.php
89 lines (56 loc) · 2.35 KB
/
Sales.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of SalesManager
*
* @author root
*/
require_once('ripcord.php');
require_once('Odoo.php');
class Sales {
var $odoo;
public function __construct($odoo) {
$this->odoo = $odoo;
}
function displaySaleOrder() {
$name = $_POST['name'];
$models = ripcord::client($this->odoo->url . "/xmlrpc/2/object");
$order = $models->execute_kw($this->odoo->db, $this->odoo->user_id, $this->odoo->password, 'sale.order', 'search_read', array(array(array('customer', '=', true), array('name', '=', $name))), array(
'limit' => 1,
'fields' => array(
'name',
'state',
'date_order',
'user_id')))[0];
echo json_encode($order);
}
function displayAllSalesOrders() {
$name = $_POST['name'];
$models = ripcord::client($this->odoo->url . "/xmlrpc/2/object");
$order = $models->execute_kw($this->odoo->db, $this->odoo->user_id, $this->odoo->password, 'sale.order', 'search_read', array(array(array('customer', '=', true), array('name', '=', $name))), array(
'limit' => 200,
'fields' => array(
'name',
'state',
'date_order',
'user_id')));
echo json_encode($order);
}
function addSaleOrder() {
$customer_id = 0;
$name = $_POST['name'];
$models = ripcord::client($this->odoo->url . "/xmlrpc/2/object");
$customer_ids = $models->execute_kw($this->odoo->db, $this->odoo->user_id, $this->odoo->password, 'res.partner', 'search_read', array(array(array('customer', '=', true), array('name', '=', $name))), array(
'limit' => 1,
'fields' => array('id')))[0];
foreach ($customer_ids as $uid) {
$customer_id = $uid;
}
$id = $models->execute_kw($this->odoo->db, $this->odoo->user_id, $this->odoo->password, 'sale.order', 'create', array(array('partner_id' => $customer_id,)));
echo json_encode($id);
}
}