# Statement Helper Functions

### function add\_statement($statement) {.....}

#### **Supported hooks**

**Filter name:**  before\_add\_statement\
**Description:** This filter would be executed before add statement into the database in add\_statement  helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘before_add_statement’, ‘before_add_statement_callback_fun’, 10, 1 );

function before_add_statement_callback_fun($statement) {
 // code
}
```

**Filter name:**  should\_add\_statement\
**Description:** This filter would be executed before add statement into database in add\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘should_add_statement’, ‘should_add_statement_callback_fun’, 10, 1 );

function should_add_statement_callback_fun($statement) {
    // code
}

```

**hook name:**  pre.add.statement\
**Description:** This hook would be executed before add statement into the database in add\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('pre.add.statement', 'pre_add_statement_callback_fun', 10, 1);

function pre_add_statement_callback_fun($statement) {
    // code
}
```

**hook name:**  post.add.statement\
**Description:** This hook would be executed after add statement into the database in add\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('post.add.statement', 'post_add_statement_callback_fun', 10, 1);

function post_add_statement_callback_fun($statement) {
    // code
}
```

**Usage**

```php
// for use statement helper you need to add this helper on controller or
// you can autoload this helper.
$this->load->helper('includes/statement');

// add a new statement in statement table.
$statement_id = add_statement($statement);
```

**Request Parameters**

Parameters in array format includes following attributes:

| Param             | Type       | Required | Default | Description                                                                       |
| ----------------- | ---------- | -------- | ------- | --------------------------------------------------------------------------------- |
| statement\_number | Integer    | Yes      | Null    | The statement\_number of a specific statement.                                    |
| creation\_date    | Date\_time |          | Null    | the creation\_date for specific statement ( must provide date in gmdate() format) |
| statement\_name   | Character  | Yes      | Null    | The statement\_name  for specific statement.                                      |
| booking\_id       | Integer    | Yes      | Null    | The booking\_id create for a specific booking statement.                          |

**Response**

```
Response includes the following attributes:
if data have been added successfully it would return the key of specific statement id.

```

```php
return $statement_id;
```

```
if data does not add it will return null.
```

### function get\_statement($statement\_id) {....}

#### **Supported hooks**

**Filter name:**  before\_get\_statement\
**Description:** This filter would be executed before retrieving statement details from database in get\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘before_get_statement’, ‘before_get_statement_callback_fun’, 10, 1 );

function before_get_statement_callback_fun($statement_id) {
 // code
}
```

**Filter name:**  should\_get\_statement\
**Description:** This filter would be executed before retrieving statement details from database in get\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘should_get_statement’, ‘should_get_statement_callback_fun’, 10, 1 );

function should_get_statement_callback_fun($statement_id) {
    // code
}
```

**hook name:**  pre.get.statement\
**Description:** This hook would be executed before retrieving statement details from database in get\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('pre.get.statement', 'pre_get_statement_callback_fun', 10, 1);

function pre_get_statement_callback_fun($statement_id) {
    // code
}
```

**hook name:**  post.get.statement\
**Description:** This hook would be executed after retrieving statement details from database in get\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('post.get.statement', 'post_get_statement_callback_fun', 10, 1);

function post_get_statement_callback_fun($statement_id) {
    // code
}
```

**Usage**

```php
// Retrieves statementdata based on a statement_id.
$statement_data = get_statement($statement_id);


```

**Request Parameters**

| Param          | Type    | Required | Default | Description                                                |
| -------------- | ------- | -------- | ------- | ---------------------------------------------------------- |
| $statement\_id | Integer | Yes      | Null    | The id of the statement corresponds to the statement table |

**Response**

```php
// $response array includes following attributes:
// $response['statement_number'] : the statement_number of specific statement.
// $response['creation_date'] : the creation_date for specific statement .
// $response['statement_name'] : the statement_name for specific statement.
// $response['booking_id'] : the booking_id for specific statement.
// and many more attributes for table statement and join with booking_x_statement table.

// Successfully response giving you array of statement data.

Array
(
    [0] => Array
        (
            [statement_id] => 1
            [statement_number] => 0
            [is_deleted] => 0
            [creation_date] => 2022-01-24 05:58:43
            [statement_name] => booking create 
            [booking_id] => 1
        )

)

// If there is no statement data for any statement id provided in input or any error will return null.
```

### function get\_statements($filter) {.....}

**Supported hooks**

**Filter name:**  before\_get\_statements\
**Description:** This filter would be executed before retrieving statement details from database in get\_statements helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘before_get_statements’, ‘before_get_statements_callback_fun’, 10, 1 );

function before_get_statements_callback_fun($filter) {
 // code
}
```

**Filter name:**  should\_get\_statements\
**Description:** This filter would be executed before retrieving statement details from database in get\_statements helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘should_get_statements’, ‘should_get_statements_callback_fun’, 10, 1 );

function should_get_statements_callback_fun($filter) {
    // code
}

```

**hook name:**  pre.get.statements\
**Description:** This hook would be executed before retrieving statement details from database in get\_statements helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('pre.get.statements', 'pre_get_statements_callback_fun', 10, 1);

function pre_get_statements_callback_fun($filter) {
    // code
}
```

**hook name:**  post.get.statements\
**Description:** This hook would be executed after retrieving statement details from database in get\_statements helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('post.get.statements', 'post_get_statements_callback_fun', 10, 1);

function post_get_statements_callback_fun($filter) {
    // code
}
```

**Usage**

```php

// Retrieves statement data based on a filter array.
$statement_data = get_statements($filter);
```

**Request Parameters**

parameter array filter required for statement details.

| Param           | Type      | Required | Default | Description                                   |
| --------------- | --------- | -------- | ------- | --------------------------------------------- |
| statement\_name | Character | Yes      | Null    | The statement\_name for a specific statement. |
| booking\_id     | Integer   | Yes      | Null    | The booking\_id  for specific statement.      |

**Response**

```php
// $response array includes following attributes:
// $response['statement_number'] : the statement_number of specific statement.
// $response['creation_date'] : the creation_date for specific statement .
// $response['statement_name'] : the statement_name for specific statement.
// $response['booking_id'] : the booking_id for specific statement.
// and many more attributes for table statement and join with booking_x_statement table.

// Successfully response giving you array of statement data.

Array
(
    [0] => Array
        (
            [statement_id] => 1
            [statement_number] => 0
            [is_deleted] => 0
            [creation_date] => 2022-01-24 05:58:43
            [statement_name] => booking create must need
            [booking_id] => 1
        )

)

// If there is no statement data for filter provided in input or any error will return null.
```

### function update\_statement($statement, $statement\_id) {....}

**Usage**

```php
// update statement data based on a statement array data and statement_id.
 update_statement($statement, $statement_id);
```

**Supported hooks**

**Filter name:**  before\_update\_statement\
**Description:** This filter would be executed before update statement into the database in update\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘before_update_statement’, ‘before_update_statement_callback_fun’, 10, 1 );

function before_update_statement_callback_fun($statement, $statement_id) {
 // code
}
```

**Filter name:**  should\_update\_statement\
**Description:** This filter would be executed before update tax into database in update\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘should_update_statement’, ‘should_update_statement_callback_fun’, 10, 1 );

function should_update_statement_callback_fun($statement, $statement_id) {
    // code
}

```

**hook name:**  pre.update.statement\
**Description:** This hook would be executed before update statement into the database in update\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('pre.update.statement', 'pre_update_statement_callback_fun', 10, 1);

function pre_update_statement_callback_fun($statement, $statement_id) {
    // code
}
```

**hook name:**  post.update.statement\
**Description:** This hook would be executed after update statement into the database in update\_statement helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('post.update.statement', 'post_update_statement_callback_fun', 10, 1);

function post_update_statement_callback_fun($statement, $statement_id) {
    // code
}
```

**Request Parameters**

Request required statement\_id and  array format data includes following attributes:

<table><thead><tr><th width="215">Param</th><th>Type</th><th>Required</th><th>Default</th><th>Description</th><th></th></tr></thead><tbody><tr><td>statement_number</td><td>Integer</td><td>Yes</td><td>Null</td><td>The statement_number of a specific statement.</td><td></td></tr><tr><td>creation_date</td><td>Date_time</td><td></td><td>Null</td><td>the creation_date for specific statement ( must provide date in gmdate() format)</td><td></td></tr><tr><td>statement_name</td><td>Character</td><td>Yes</td><td>Null</td><td>The statement_name  for specific statement.</td><td></td></tr><tr><td>booking_id</td><td>Integer</td><td>Yes</td><td>Null</td><td>The booking_id create for a specific booking statement.</td><td></td></tr></tbody></table>

**Response**

```
Response return mixed Either true or null if statement data is updated then true else null.
```

### **function delete\_**&#x73;tatement **(**$statement\_i&#x64;**) {.....}**

**Usage**

```php
// delete a statement data from the statement table. it's a soft delete process only status will change data still existing in the backend database.

 delete_statement($statement_id);
```

**Request Parameters**

| Param           | Type    | Required | Default | Description                                                |
| --------------- | ------- | -------- | ------- | ---------------------------------------------------------- |
| $statement \_id | integer | yes      | null    | The id of the statement corresponds to the statement table |

**Response**

```
Response return mixed Either true or null if statement data is deleted then true 
else null.
```
