答:
Since you are passing an array from your Ajax call, you will need to build a SQL query using that:

```<code>$sql = "DELETE FROM doctor WHERE DOC_LICENSE_NUM IN (" . implode(",", $_POST['id']) . ".)";

// Execute
 if ($mydatabase->mysqli_query($sql) === TRUE) {
     echo "<div>Record deleted successfully</div>";
 } else {
    echo "Error deleting record: " . $mydatabase->error;
 }
</code>```

Note: You're open to SQL Injection. Always use prepared statements when your query requires parameters by others for it to execute. This could be a little help.

Title: $.ajax does not delete multiple table rows with checkbox

Body:
Since you are passing an array from your Ajax call, you will need to build a SQL query using that:

$sql = "DELETE FROM doctor WHERE DOC_LICENSE_NUM IN (" . implode(",", $_POST['id']) . ".)";

// Execute
 if ($mydatabase->mysqli_query($sql) === TRUE) {
     echo "<div>Record deleted successfully</div>";
 } else {
    echo "Error deleting record: " . $mydatabase->error;
 }

Note: You're open to SQL Injection. Always use prepared statements when your query requires parameters by others for it to execute. This could be a little help.


来源: stackexchange

答:
```<code>select *
from api_keys as a
left join (
    select key_val
    from Used_Keys
    group by key_val
    having count(*) >= 3
    ) as u on a.key_val = u.key_val
where u.key_val IS NULL
</code>```

ContentLicense: CC BY-SA 3.0

Title: MySQL check if same value exist in another table for three times

Body:
I have two MySQL tables:

API_Keys
+----+---------------+--------------+
| id | key_val       | Expiration |
+----+---------------+--------------+
| 1  | 111111111111  | 2018-11-13 |
+----+---------------+--------------+
| 2  | 222222222222  | 2018-11-13 |
+----+---------------+--------------+
| 3  | 333333333333  | 2018-12-13 |
+----+---------------+--------------+
| 3  | 444444444444  | 2018-11-13 |

Used_Keys
+----+------+--------------+
| id | user | key_val      |
+----+------+--------------+
| 1  | john | 111111111111 |
+----+------+--------------+
| 2  | sami | 111111111111 |
+----+------+--------------+
| 3  | mary | 111111111111 |
+----+------+--------------+
| 4  | nina | 333333333333 |
+----+------+--------------+
| 5  | leon | 333333333333 |

Each key_val can be assigned to the maximum of 3 users.
So I need to list all API_Keys table data, except the key_vals that are assigned 3 times already in Used_Keys table.

So the desired result of free API_Keys would be:

API_Keys
+----+---------------+--------------+
| id | key_val       | Expiration |
+----+---------------+--------------+
| 1  | 222222222222  | 2018-11-13 |
+----+---------------+--------------+
| 2  | 333333333333  | 2018-12-13 |
+----+---------------+--------------+
| 3  | 444444444444  | 2018-11-13 |

I would appropriate if you help me to write the MySQL select query for this purpose.


问:
Quartz vs. ScheduledExecutorService in Java web application
For a system monitoring Java application which currently runs on the command line and uses ScheduledExecutorService, I would like to write a simple web application version, to be run in a Servlet container like Apache Tomcat or Eclipse Jetty.

I have read about Quartz as one of the popular job schedulers for web applications. Would it be better (maybe because of better servlet container integration) to port this application from ScheduledExecutorService to Quartz?

Adding another library dependency to the application is not a problem, I am interested in technical reasons against usage of ScheduledExecutorService.

答:
ScheduledExecutorService operates at a lower level and you'd have to implement all scheduling monitoring/maintenance facilities yourself.

Quartz has tons of facilities such as Job Persistence, Transactions, Clustering etc.

ContentLicense: CC BY-SA 2.5


问:
How can I center a text and keep being left align?
Here is a simplified of my code:

.wrapper{
  border: 1px solid gray;
  width: 30%;
  margin: 20px auto;
}
.icon{
  text-align: center;
}

.icon i{
  font-size: 100px;
  color: gray;
}
.text{
  text-align: center;
}
.text span{
  display: block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<div class="wrapper">

  <div class="icon">
    <i class="fa fa-home" aria-hidden="true"></i>
  </div>
  <div class="text">
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Something </span>
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Something Else </span>
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Some </span>
  </div>

</div></code>```

All I want to do is putting all check icons exactly under each other vertically. How can I do that?

答:
With a simple margin:auto and text-align:left  in the div.text you can achieve this:

.wrapper{
  border: 1px solid gray;
  width: 30%;
  margin: 20px auto;
}
.icon{
  text-align: center;
}

.icon i{
  font-size: 100px;
  color: gray;
}
.text{
  text-align: left;
  margin: auto;
  width: 70%;
}
.text span{
  display: block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<div class="wrapper">

  <div class="icon">
    <i class="fa fa-home" aria-hidden="true"></i>
  </div>
  <div class="text">
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Something </span>
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Something Else </span>
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Some </span>
  </div>

</div></code>```

Body:
Here is a simplified of my code:

.wrapper{
  border: 1px solid gray;
  width: 30%;
  margin: 20px auto;
}
.icon{
  text-align: center;
}

.icon i{
  font-size: 100px;
  color: gray;
}
.text{
  text-align: center;
}
.text span{
  display: block;
}

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

     Something
     Something Else
     Some

All I want to do is putting all check icons exactly under each other vertically. How can I do that?

Body:
With a simple margin:auto and text-align:left  in the div.text you can achieve this:

.wrapper{
  border: 1px solid gray;
  width: 30%;
  margin: 20px auto;
}
.icon{
  text-align: center;
}

.icon i{
  font-size: 100px;
  color: gray;
}
.text{
  text-align: left;
  margin: auto;
  width: 70%;
}
.text span{
  display: block;
}

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<div class="wrapper">

  <div class="icon">
    <i class="fa fa-home" aria-hidden="true"></i>
  </div>
  <div class="text">
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Something </span>
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Something Else </span>
    <span><i class="fa fa-check-square" aria-hidden="true"></i> Some </span>
  </div>

</div>


问:
Conditional join in data.table?
I have the following data.table, dtgrouped2:

```<code>     MonthNo Unique Total
 1:       1    AAA    10
 2:       1    BBB     0
 3:       2    CCC     3
 4:       2    DDD     0
 5:       3    AAA     0
 6:       3    BBB    35
 7:       4    CCC    15
 8:       4    AAA     0
 9:       5    BBB    60
10:       5    CCC     0
11:       6    DDD   100
12:       6    AAA     0
</code>```

And another table, dt2:

```<code>     Unique1 StartDate EndDate Amount1 Amount2
1:     AAA        0        1       7       0
3:     AAA        1        2       5       0
2:     AAA        2        4       3       2
</code>```

I want to insert Amount1 and Amount2 from dt2 to dtgrouped2 based on the following logic on "Unique" evaluated for each row of dtgrouped2:

```<code>filter(StartDate< MonthNo & EndDate>=MonthNo)
then MAX(EndDate)
then insert Amount1 as Amount1 and Amount2 as Amount2
</code>```

So you can see that the result is different depending on the row. This would be the expected output:

```<code>Date    MonthNo Unique  Items   Amounts Amount1 Amount2
Jan       1      AAA    x         10        7   0
Jan       1      BBB    y          2        NA  NA
Feb       2      CCC    x          3        NA  NA
Feb       2      DDD    y         15       NA   NA
March     3      AAA    y         20        3   2
March     3      BBB    x         35       NA   NA
April     4      CCC    x         15       NA   NA
April     4      AAA    y         50       3    2
May       5      BBB    x         60      NA    NA
May       5      CCC    y         70      NA    NA
June      6      DDD    x         100     NA    NA
June      6      AAA    y         20       NA   NA
</code>```

答:
I suggest to use non-equi joins combined with mult = "last" (in order to capture only the most recent EndDate)

```<code>dtgrouped2[, c("Amount1", "Amount2") := # Assign the below result to new columns in dtgrouped2
              dt2[dtgrouped2, # join
                  .(Amount1, Amount2), # get the column you need
                  on = .(Unique1 = Unique, # join conditions
                         StartDate < MonthNo,
                         EndDate >= MonthNo),
                  mult = "last"]] # get always the latest EndDate
dtgrouped2

#     MonthNo Unique Total Amount1 Amount2
#  1:       1    AAA    10       7       0
#  2:       1    BBB     0      NA      NA
#  3:       2    CCC     3      NA      NA
#  4:       2    DDD     0      NA      NA
#  5:       3    AAA     0       3       2
#  6:       3    BBB    35      NA      NA
#  7:       4    CCC    15      NA      NA
#  8:       4    AAA     0       3       2
#  9:       5    BBB    60      NA      NA
# 10:       5    CCC     0      NA      NA
# 11:       6    DDD   100      NA      NA
# 12:       6    AAA     0      NA      NA
</code>```

The reason that you would need to join dt2[dtgrouped] first (and not the other way around) is because you want to join dt2 for each possible value in dtgrouped, hence allow multiple values in dt2 to be joined to dtgrouped

Title: Conditional join in data.table?

Body:
I have the following data.table, dtgrouped2:

     MonthNo Unique Total
 1:       1    AAA    10
 2:       1    BBB     0
 3:       2    CCC     3
 4:       2    DDD     0
 5:       3    AAA     0
 6:       3    BBB    35
 7:       4    CCC    15
 8:       4    AAA     0
 9:       5    BBB    60
10:       5    CCC     0
11:       6    DDD   100
12:       6    AAA     0

And another table, dt2:

     Unique1 StartDate EndDate Amount1 Amount2
1:     AAA        0        1       7       0
3:     AAA        1        2       5       0
2:     AAA        2        4       3       2

I want to insert Amount1 and Amount2 from dt2 to dtgrouped2 based on the following logic on "Unique" evaluated for each row of dtgrouped2:

filter(StartDate< MonthNo & EndDate>=MonthNo)
then MAX(EndDate)
then insert Amount1 as Amount1 and Amount2 as Amount2

So you can see that the result is different depending on the row. This would be the expected output:

Date    MonthNo Unique  Items   Amounts Amount1 Amount2
Jan       1      AAA    x         10        7   0
Jan       1      BBB    y          2        NA  NA
Feb       2      CCC    x          3        NA  NA
Feb       2      DDD    y         15       NA   NA
March     3      AAA    y         20        3   2
March     3      BBB    x         35       NA   NA
April     4      CCC    x         15       NA   NA
April     4      AAA    y         50       3    2
May       5      BBB    x         60      NA    NA
May       5      CCC    y         70      NA    NA
June      6      DDD    x         100     NA    NA
June      6      AAA    y         20       NA   NA

Body:
I suggest to use non-equi joins combined with mult = "last" (in order to capture only the most recent EndDate)

dtgrouped2[, c("Amount1", "Amount2") := # Assign the below result to new columns in dtgrouped2
              dt2[dtgrouped2, # join
                  .(Amount1, Amount2), # get the column you need
                  on = .(Unique1 = Unique, # join conditions
                         StartDate < MonthNo,
                         EndDate >= MonthNo),
                  mult = "last"]] # get always the latest EndDate
dtgrouped2

#     MonthNo Unique Total Amount1 Amount2
#  1:       1    AAA    10       7       0
#  2:       1    BBB     0      NA      NA
#  3:       2    CCC     3      NA      NA
#  4:       2    DDD     0      NA      NA
#  5:       3    AAA     0       3       2
#  6:       3    BBB    35      NA      NA
#  7:       4    CCC    15      NA      NA
#  8:       4    AAA     0       3       2
#  9:       5    BBB    60      NA      NA
# 10:       5    CCC     0      NA      NA
# 11:       6    DDD   100      NA      NA
# 12:       6    AAA     0      NA      NA

The reason that you would need to join dt2[dtgrouped] first (and not the other way around) is because you want to join dt2 for each possible value in dtgrouped, hence allow multiple values in dt2 to be joined to dtgrouped


问:
isset($_POST['submit'] not set after submitting my form
I'm new to php and I'm trying to register a user to a database using a form.

This is the code for the form (using the bootstrap framework):

```<code><form class="form-horizontal" role="form" method="POST" action="connectivity-reserve.php">
                <div class="form-group">
                    <label class="col-sm-2 control-label">Customer's name</label>
                    <div class="col-sm-6">
                        <div class="input-group">
                        <input type="text" class="form-control" id="Customername" name="Customername" placeholder="Customer name">
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">Password</label>
                    <div class="col-sm-6">
                        <div class="input-group">
                        <input type="password" class="form-control" id="pwd" name="pwd" placeholder="Password">
                        </div>
                    </div>
                </div>

                </div>
                 <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" name ="submit" class="btn btn-primary">Reserve</button>
                    <button type="button" class="btn btn-default btn-sm"
                   data-dismiss="modal">Cancel</button>
                    </div>
                </div>
                <div class="form-group">
                <div class="alert alert-warning alert-dismissible" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">×</span>
                    </button>
                    <strong>Warning:</strong>: Please <a href="tel:+85212345678" class="alert-link">
                    call</a> us to reserve for more than six guests.
                </div>
                </div>
            </form>
</code>```

Here is the file (mysqli_connect.php) for connecting to the database. This is working:

```<code><?php
// This provides the information for accessing the database.
// It also creates a connection to MySQL,
// It selects the database, and sets the encoding.
// Set the database access information as constants:
DEFINE ('DB_USER', 'xxxx');
DEFINE ('DB_PASSWORD', 'xxxx');
DEFINE ('DB_HOST', 'xxxx');
DEFINE ('DB_NAME', 'xxxx');
// Make the connection:
$dbcon = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );
// Set the encoding...
mysqli_set_charset($dbcon, 'utf8');
</code>```

The file connectivity-reserve.php is what I'm using to add the user into the database.
Here is the code:

```<code><?php
require ('mysqli_connect.php');

echo "yay";

if(isset($_POST['submit']))
{

$Customername = $_POST['Customername'];
$pwd  = $_POST['pwd'];
$q = "INSERT INTO users (user_id, cname, psword, ) VALUES (' ', '$Customername', '$pwd')";

 $result = @mysqli_query ($dbcon, $q);

 if($result)
    {
        echo "YOUR REGISTRATION IS COMPLETED...";
    }
    else
    {
        echo "nah";
    }
}

?>
</code>```

I'm able to connect to the database since the code echo "yay" is displayed on the browser. The issue is with the if(isset($_POST['submit'])) condition. I thought it should work since my button's type and name are 'submit' on the form:

```<code><button type="submit" name ="submit" class="btn btn-primary">Reserve</button>
</code>```

Help will be greatly appreciated.

Edit: Thanks guys! It was the , after psword. Also I know the code isn't secure. I'm just starting out with php so that isn't really a priority for me right now.

答:
```<code>INSERT INTO users (cname, psword, ) VALUES ('{$Customername}', '{$pwd}')
</code>```

You Should remove user_id because its already auto i

Body:
I'm new to php and I'm trying to register a user to a database using a form.

This is the code for the form (using the bootstrap framework):

<form class="form-horizontal" role="form" method="POST" action="connectivity-reserve.php">

                    Customer's name

                        <input type="text" class="form-control" id="Customername" name="Customername" placeholder="Customer name">

                    Password

                        <input type="password" class="form-control" id="pwd" name="pwd" placeholder="Password">

                    <button type="submit" name ="submit" class="btn btn-primary">Reserve</button>
                    <button type="button" class="btn btn-default btn-sm"
                   data-dismiss="modal">Cancel</button>

                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    ×
                    </button>
                    Warning:: Please
                    call us to reserve for more than six guests.

            </form>

Here is the file (mysqli_connect.php) for connecting to the database. This is working:

<?php
// This provides the information for accessing the database.
// It also creates a connection to MySQL,
// It selects the database, and sets the encoding.
// Set the database access information as constants:
DEFINE ('DB_USER', 'xxxx');
DEFINE ('DB_PASSWORD', 'xxxx');
DEFINE ('DB_HOST', 'xxxx');
DEFINE ('DB_NAME', 'xxxx');
// Make the connection:
$dbcon = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );
// Set the encoding...
mysqli_set_charset($dbcon, 'utf8');

The file connectivity-reserve.php is what I'm using to add the user into the database.
Here is the code:

<?php
require ('mysqli_connect.php');

echo "yay";

if(isset($_POST['submit']))
{

$Customername = $_POST['Customername'];
$pwd  = $_POST['pwd'];
$q = "INSERT INTO users (user_id, cname, psword, ) VALUES (' ', '$Customername', '$pwd')";

 $result = @mysqli_query ($dbcon, $q);

 if($result)
    {
        echo "YOUR REGISTRATION IS COMPLETED...";
    }
    else
    {
        echo "nah";
    }
}

?>

I'm able to connect to the database since the code echo "yay" is displayed on the browser. The issue is with the if(isset($_POST['submit'])) condition. I thought it should work since my button's type and name are 'submit' on the form:

<button type="submit" name ="submit" class="btn btn-primary">Reserve</button>

Help will be greatly appreciated.

Edit: Thanks guys! It was the , after psword. Also I know the code isn't secure. I'm just starting out with php so that isn't really a priority for me right now.

Body:
INSERT INTO users (cname, psword, ) VALUES ('{$Customername}', '{$pwd}')

You Should remove user_id because its already auto i


问:
How to refresh opencart modification by code
I need to refresh modifications after install module.

```<code>public function install() {
    $this->load->controller('marketplace/modification/refresh');
}
</code>```

I tried this. Its worked but the page redirected to modification listing. How can i do without redirect. I am using opencart 3.

答:
You could not controll by this way as you are doing:

You need to do this as

```<code>public function install() {
    $this->refresh();
  }

   protected function refresh($data = array()) {
        $this->load->language('marketplace/modification');

        $this->document->setTitle($this->language->get('heading_title'));

        $this->load->model('setting/modification');

        if ($this->validate()) {
            // Just before files are deleted, if config settings say maintenance mode is off then turn it on
            $maintenance = $this->config->get('config_maintenance');

            $this->load->model('setting/setting');

            $this->model_setting_setting->editSettingValue('config', 'config_maintenance', true);

            //Log
            $log = array();

            // Clear all modification files
            $files = array();

            // Make path into an array
            $path = array(DIR_MODIFICATION . '*');

            // While the path array is still populated keep looping through
            while (count($path) != 0) {
                $next = array_shift($path);

                foreach (glob($next) as $file) {
                    // If directory add to path array
                    if (is_dir($file)) {
                        $path[] = $file . '/*';
                    }

                    // Add the file to the files to be deleted array
                    $files[] = $file;
                }
            }

            // Reverse sort the file array
            rsort($files);

            // Clear all modification files
            foreach ($files as $file) {
                if ($file != DIR_MODIFICATION . 'index.html') {
                    // If file just delete
                    if (is_file($file)) {
                        unlink($file);

                    // If directory use the remove directory function
                    } elseif (is_dir($file)) {
                        rmdir($file);
                    }
                }
            }

            // Begin
            $xml = array();

            // Load the default modification XML
            $xml[] = file_get_contents(DIR_SYSTEM . 'modification.xml');

            // This is purly for developers so they can run mods directly and have them run without upload after each change.
            $files = glob(DIR_SYSTEM . '*.ocmod.xml');

            if ($files) {
                foreach ($files as $file) {
                    $xml[] = file_get_contents($file);
                }
            }

            // Get the default modification file
            $results = $this->model_setting_modification->getModifications();

            foreach ($results as $result) {
                if ($result['status']) {
                    $xml[] = $result['xml'];
                }
            }

            $modification = array();

            foreach ($xml as $xml) {
                if (empty($xml)){
                    continue;
                }

                $dom = new DOMDocument('1.0', 'UTF-8');
                $dom->preserveWhiteSpace = false;
                $dom->loadXml($xml);

                // Log
                $log[] = 'MOD: ' . $dom->getElementsByTagName('name')->item(0)->textContent;

                // Wipe the past modification store in the backup array
                $recovery = array();

                // Set the a recovery of the modification code in case we need to use it if an abort attribute is used.
                if (isset($modification)) {
                    $recovery = $modification;
                }

                $files = $dom->getElementsByTagName('modification')->item(0)->getElementsByTagName('file');

                foreach ($files as $file) {
                    $operations = $file->getElementsByTagName('operation');

                    $files = explode('|', $file->getAttribute('path'));

                    foreach ($files as $file) {
                        $path = '';

                        // Get the full path of the files that are going to be used for modification
                        if ((substr($file, 0, 7) == 'catalog')) {
                            $path = DIR_CATALOG . substr($file, 8);
                        }

                        if ((substr($file, 0, 5) == 'admin')) {
                            $path = DIR_APPLICATION . substr($file, 6);
                        }

                        if ((substr($file, 0, 6) == 'system')) {
                            $path = DIR_SYSTEM . substr($file, 7);
                        }

                        if ($path) {
                            $files = glob($path, GLOB_BRACE);

                            if ($files) {
                                foreach ($files as $file) {
                                    // Get the key to be used for the modification cache filename.
                                    if (substr($file, 0, strlen(DIR_CATALOG)) == DIR_CATALOG) {
                                        $key = 'catalog/' . substr($file, strlen(DIR_CATALOG));
                                    }

                                    if (substr($file, 0, strlen(DIR_APPLICATION)) == DIR_APPLICATION) {
                                        $key = 'admin/' . substr($file, strlen(DIR_APPLICATION));
                                    }

                                    if (substr($file, 0, strlen(DIR_SYSTEM)) == DIR_SYSTEM) {
                                        $key = 'system/' . substr($file, strlen(DIR_SYSTEM));
                                    }

                                    // If file contents is not already in the modification array we need to load it.
                                    if (!isset($modification[$key])) {
                                        $content = file_get_contents($file);

                                        $modification[$key] = preg_replace('~\r?\n~', "\n", $content);
                                        $original[$key] = preg_replace('~\r?\n~', "\n", $content);

                                        // Log
                                        $log[] = PHP_EOL . 'FILE: ' . $key;
                                    }

                                    foreach ($operations as $operation) {
                                        $error = $operation->getAttribute('error');

                                        // Ignoreif
                                        $ignoreif = $operation->getElementsByTagName('ignoreif')->item(0);

                                        if ($ignoreif) {
                                            if ($ignoreif->getAttribute('regex') != 'true') {
                                                if (strpos($modification[$key], $ignoreif->textContent) !== false) {
                                                    continue;
                                                }
                                            } else {
                                                if (preg_match($ignoreif->textContent, $modification[$key])) {
                                                    continue;
                                                }
                                            }
                                        }

                                        $status = false;

                                        // Search and replace
                                        if ($operation->getElementsByTagName('search')->item(0)->getAttribute('regex') != 'true') {
                                            // Search
                                            $search = $operation->getElementsByTagName('search')->item(0)->textContent;
                                            $trim = $operation->getElementsByTagName('search')->item(0)->getAttribute('trim');
                                            $index = $operation->getElementsByTagName('search')->item(0)->getAttribute('index');

                                            // Trim line if no trim attribute is set or is set to true.
                                            if (!$trim || $trim == 'true') {
                                                $search = trim($search);
                                            }

                                            // Add
                                            $add = $operation->getElementsByTagName('add')->item(0)->textContent;
                                            $trim = $operation->getElementsByTagName('add')->item(0)->getAttribute('trim');
                                            $position = $operation->getElementsByTagName('add')->item(0)->getAttribute('position');
                                            $offset = $operation->getElementsByTagName('add')->item(0)->getAttribute('offset');

                                            if ($offset == '') {
                                                $offset = 0;
                                            }

                                            // Trim line if is set to true.
                                            if ($trim == 'true') {
                                                $add = trim($add);
                                            }

                                            // Log
                                            $log[] = 'CODE: ' . $search;

                                            // Check if using indexes
                                            if ($index !== '') {
                                                $indexes = explode(',', $index);
                                            } else {
                                                $indexes = array();
                                            }

                                            // Get all the matches
                                            $i = 0;

                                            $lines = explode("\n", $modification[$key]);

                                            for ($line_id = 0; $line_id < count($lines); $line_id++) {
                                                $line = $lines[$line_id];

                                                // Status
                                                $match = false;

                                                // Check to see if the line matches the search code.
                                                if (stripos($line, $search) !== false) {
                                                    // If indexes are not used then just set the found status to true.
                                                    if (!$indexes) {
                                                        $match = true;
                                                    } elseif (in_array($i, $indexes)) {
                                                        $match = true;
                                                    }

                                                    $i++;
                                                }

                                                // Now for replacing or adding to the matched elements
                                                if ($match) {
                                                    switch ($position) {
                                                        default:
                                                        case 'replace':
                                                            $new_lines = explode("\n", $add);

                                                            if ($offset < 0) {
                                                                array_splice($lines, $line_id + $offset, abs($offset) + 1, array(str_replace($search, $add, $line)));

                                                                $line_id -= $offset;
                                                            } else {
                                                                array_splice($lines, $line_id, $offset + 1, array(str_replace($search, $add, $line)));
                                                            }
                                                            break;
                                                        case 'before':
                                                            $new_lines = explode("\n", $add);

                                                            array_splice($lines, $line_id - $offset, 0, $new_lines);

                                                            $line_id += count($new_lines);
                                                            break;
                                                        case 'after':
                                                            $new_lines = explode("\n", $add);

                                                            array_splice($lines, ($line_id + 1) + $offset, 0, $new_lines);

                                                            $line_id += count($new_lines);
                                                            break;
                                                    }

                                                    // Log
                                                    $log[] = 'LINE: ' . $line_id;

                                                    $status = true;
                                                }
                                            }

                                            $modification[$key] = implode("\n", $lines);
                                        } else {
                                            $search = trim($operation->getElementsByTagName('search')->item(0)->textContent);
                                            $limit = $operation->getElementsByTagName('search')->item(0)->getAttribute('limit');
                                            $replace = trim($operation->getElementsByTagName('add')->item(0)->textContent);

                                            // Limit
                                            if (!$limit) {
                                                $limit = -1;
                                            }

                                            // Log
                                            $match = array();

                                            preg_match_all($search, $modification[$key], $match, PREG_OFFSET_CAPTURE);

                                            // Remove part of the the result if a limit is set.
                                            if ($limit > 0) {
                                                $match[0] = array_slice($match[0], 0, $limit);
                                            }

                                            if ($match[0]) {
                                                $log[] = 'REGEX: ' . $search;

                                                for ($i = 0; $i < count($match[0]); $i++) {
                                                    $log[] = 'LINE: ' . (substr_count(substr($modification[$key], 0, $match[0][$i][1]), "\n") + 1);
                                                }

                                                $status = true;
                                            }

                                            // Make the modification
                                            $modification[$key] = preg_replace($search, $replace, $modification[$key], $limit);
                                        }

                                        if (!$status) {
                                            // Abort applying this modification completely.
                                            if ($error == 'abort') {
                                                $modification = $recovery;
                                                // Log
                                                $log[] = 'NOT FOUND - ABORTING!';
                                                break 5;
                                            }
                                            // Skip current operation or break
                                            elseif ($error == 'skip') {
                                                // Log
                                                $log[] = 'NOT FOUND - OPERATION SKIPPED!';
                                                continue;
                                            }
                                            // Break current operations
                                            else {
                                                // Log
                                                $log[] = 'NOT FOUND - OPERATIONS ABORTED!';
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // Log
                $log[] = '----------------------------------------------------------------';
            }

            // Log
            $ocmod = new Log('ocmod.log');
            $ocmod->write(implode("\n", $log));

            // Write all modification files
            foreach ($modification as $key => $value) {
                // Only create a file if there are changes
                if ($original[$key] != $value) {
                    $path = '';

                    $directories = explode('/', dirname($key));

                    foreach ($directories as $directory) {
                        $path = $path . '/' . $directory;

                        if (!is_dir(DIR_MODIFICATION . $path)) {
                            @mkdir(DIR_MODIFICATION . $path, 0777);
                        }
                    }

                    $handle = fopen(DIR_MODIFICATION . $key, 'w');

                    fwrite($handle, $value);

                    fclose($handle);
                }
            }

            // Maintance mode back to original settings
            $this->model_setting_setting->editSettingValue('config', 'config_maintenance', $maintenance);

            // Do not return success message if refresh() was called with $data
            $this->session->data['success'] = $this->language->get('text_success');

            $url = '';

            if (isset($this->request->get['sort'])) {
                $url .= '&sort=' . $this->request->get['sort'];
            }

            if (isset($this->request->get['order'])) {
                $url .= '&order=' . $this->request->get['order'];
            }

            if (isset($this->request->get['page'])) {
                $url .= '&page=' . $this->request->get['page'];
            }

        }

    }
</code>```

I hope it shouwl work for you.
This process is used to refresh the modification when your module installing.

if you need globally this then please tell me  I will update you process.

Body:
I need to refresh modifications after install module.

public function install() {
    $this->load->controller('marketplace/modification/refresh');
}

I tried this. Its worked but the page redirected to modification listing. How can i do without redirect. I am using opencart 3.

Body:
You could not controll by this way as you are doing:

You need to do this as

public function install() {
    $this->refresh();
  }

   protected function refresh($data = array()) {
        $this->load->language('marketplace/modification');

        $this->document->setTitle($this->language->get('heading_title'));

        $this->load->model('setting/modification');

        if ($this->validate()) {
            // Just before files are deleted, if config settings say maintenance mode is off then turn it on
            $maintenance = $this->config->get('config_maintenance');

            $this->load->model('setting/setting');

            $this->model_setting_setting->editSettingValue('config', 'config_maintenance', true);

            //Log
            $log = array();

            // Clear all modification files
            $files = array();

            // Make path into an array
            $path = array(DIR_MODIFICATION . '*');

            // While the path array is still populated keep looping through
            while (count($path) != 0) {
                $next = array_shift($path);

                foreach (glob($next) as $file) {
                    // If directory add to path array
                    if (is_dir($file)) {
                        $path[] = $file . '/*';
                    }

                    // Add the file to the files to be deleted array
                    $files[] = $file;
                }
            }

            // Reverse sort the file array
            rsort($files);

            // Clear all modification files
            foreach ($files as $file) {
                if ($file != DIR_MODIFICATION . 'index.html') {
                    // If file just delete
                    if (is_file($file)) {
                        unlink($file);

                    // If directory use the remove directory function
                    } elseif (is_dir($file)) {
                        rmdir($file);
                    }
                }
            }

            // Begin
            $xml = array();

            // Load the default modification XML
            $xml[] = file_get_contents(DIR_SYSTEM . 'modification.xml');

            // This is purly for developers so they can run mods directly and have them run without upload after each change.
            $files = glob(DIR_SYSTEM . '*.ocmod.xml');

            if ($files) {
                foreach ($files as $file) {
                    $xml[] = file_get_contents($file);
                }
            }

            // Get the default modification file
            $results = $this->model_setting_modification->getModifications();

            foreach ($results as $result) {
                if ($result['status']) {
                    $xml[] = $result['xml'];
                }
            }

            $modification = array();

            foreach ($xml as $xml) {
                if (empty($xml)){
                    continue;
                }

                $dom = new DOMDocument('1.0', 'UTF-8');
                $dom->preserveWhiteSpace = false;
                $dom->loadXml($xml);

                // Log
                $log[] = 'MOD: ' . $dom->getElementsByTagName('name')->item(0)->textContent;

                // Wipe the past modification store in the backup array
                $recovery = array();

                // Set the a recovery of the modification code in case we need to use it if an abort attribute is used.
                if (isset($modification)) {
                    $recovery = $modification;
                }

                $files = $dom->getElementsByTagName('modification')->item(0)->getElementsByTagName('file');

                foreach ($files as $file) {
                    $operations = $file->getElementsByTagName('operation');

                    $files = explode('|', $file->getAttribute('path'));

                    foreach ($files as $file) {
                        $path = '';

                        // Get the full path of the files that are going to be used for modification
                        if ((substr($file, 0, 7) == 'catalog')) {
                            $path = DIR_CATALOG . substr($file, 8);
                        }

                        if ((substr($file, 0, 5) == 'admin')) {
                            $path = DIR_APPLICATION . substr($file, 6);
                        }

                        if ((substr($file, 0, 6) == 'system')) {
                            $path = DIR_SYSTEM . substr($file, 7);
                        }

                        if ($path) {
                            $files = glob($path, GLOB_BRACE);

                            if ($files) {
                                foreach ($files as $file) {
                                    // Get the key to be used for the modification cache filename.
                                    if (substr($file, 0, strlen(DIR_CATALOG)) == DIR_CATALOG) {
                                        $key = 'catalog/' . substr($file, strlen(DIR_CATALOG));
                                    }

                                    if (substr($file, 0, strlen(DIR_APPLICATION)) == DIR_APPLICATION) {
                                        $key = 'admin/' . substr($file, strlen(DIR_APPLICATION));
                                    }

                                    if (substr($file, 0, strlen(DIR_SYSTEM)) == DIR_SYSTEM) {
                                        $key = 'system/' . substr($file, strlen(DIR_SYSTEM));
                                    }

                                    // If file contents is not already in the modification array we need to load it.
                                    if (!isset($modification[$key])) {
                                        $content = file_get_contents($file);

                                        $modification[$key] = preg_replace('~\r?\n~', "\n", $content);
                                        $original[$key] = preg_replace('~\r?\n~', "\n", $content);

                                        // Log
                                        $log[] = PHP_EOL . 'FILE: ' . $key;
                                    }

                                    foreach ($operations as $operation) {
                                        $error = $operation->getAttribute('error');

                                        // Ignoreif
                                        $ignoreif = $operation->getElementsByTagName('ignoreif')->item(0);

                                        if ($ignoreif) {
                                            if ($ignoreif->getAttribute('regex') != 'true') {
                                                if (strpos($modification[$key], $ignoreif->textContent) !== false) {
                                                    continue;
                                                }
                                            } else {
                                                if (preg_match($ignoreif->textContent, $modification[$key])) {
                                                    continue;
                                                }
                                            }
                                        }

                                        $status = false;

                                        // Search and replace
                                        if ($operation->getElementsByTagName('search')->item(0)->getAttribute('regex') != 'true') {
                                            // Search
                                            $search = $operation->getElementsByTagName('search')->item(0)->textContent;
                                            $trim = $operation->getElementsByTagName('search')->item(0)->getAttribute('trim');
                                            $index = $operation->getElementsByTagName('search')->item(0)->getAttribute('index');

                                            // Trim line if no trim attribute is set or is set to true.
                                            if (!$trim || $trim == 'true') {
                                                $search = trim($search);
                                            }

                                            // Add
                                            $add = $operation->getElementsByTagName('add')->item(0)->textContent;
                                            $trim = $operation->getElementsByTagName('add')->item(0)->getAttribute('trim');
                                            $position = $operation->getElementsByTagName('add')->item(0)->getAttribute('position');
                                            $offset = $operation->getElementsByTagName('add')->item(0)->getAttribute('offset');

                                            if ($offset == '') {
                                                $offset = 0;
                                            }

                                            // Trim line if is set to true.
                                            if ($trim == 'true') {
                                                $add = trim($add);
                                            }

                                            // Log
                                            $log[] = 'CODE: ' . $search;

                                            // Check if using indexes
                                            if ($index !== '') {
                                                $indexes = explode(',', $index);
                                            } else {
                                                $indexes = array();
                                            }

                                            // Get all the matches
                                            $i = 0;

                                            $lines = explode("\n", $modification[$key]);

                                            for ($line_id = 0; $line_id < count($lines); $line_id++) {
                                                $line = $lines[$line_id];

                                                // Status
                                                $match = false;

                                                // Check to see if the line matches the search code.
                                                if (stripos($line, $search) !== false) {
                                                    // If indexes are not used then just set the found status to true.
                                                    if (!$indexes) {
                                                        $match = true;
                                                    } elseif (in_array($i, $indexes)) {
                                                        $match = true;
                                                    }

                                                    $i++;
                                                }

                                                // Now for replacing or adding to the matched elements
                                                if ($match) {
                                                    switch ($position) {
                                                        default:
                                                        case 'replace':
                                                            $new_lines = explode("\n", $add);

                                                            if ($offset < 0) {
                                                                array_splice($lines, $line_id + $offset, abs($offset) + 1, array(str_replace($search, $add, $line)));

                                                                $line_id -= $offset;
                                                            } else {
                                                                array_splice($lines, $line_id, $offset + 1, array(str_replace($search, $add, $line)));
                                                            }
                                                            break;
                                                        case 'before':
                                                            $new_lines = explode("\n", $add);

                                                            array_splice($lines, $line_id - $offset, 0, $new_lines);

                                                            $line_id += count($new_lines);
                                                            break;
                                                        case 'after':
                                                            $new_lines = explode("\n", $add);

                                                            array_splice($lines, ($line_id + 1) + $offset, 0, $new_lines);

                                                            $line_id += count($new_lines);
                                                            break;
                                                    }

                                                    // Log
                                                    $log[] = 'LINE: ' . $line_id;

                                                    $status = true;
                                                }
                                            }

                                            $modification[$key] = implode("\n", $lines);
                                        } else {
                                            $search = trim($operation->getElementsByTagName('search')->item(0)->textContent);
                                            $limit = $operation->getElementsByTagName('search')->item(0)->getAttribute('limit');
                                            $replace = trim($operation->getElementsByTagName('add')->item(0)->textContent);

                                            // Limit
                                            if (!$limit) {
                                                $limit = -1;
                                            }

                                            // Log
                                            $match = array();

                                            preg_match_all($search, $modification[$key], $match, PREG_OFFSET_CAPTURE);

                                            // Remove part of the the result if a limit is set.
                                            if ($limit > 0) {
                                                $match[0] = array_slice($match[0], 0, $limit);
                                            }

                                            if ($match[0]) {
                                                $log[] = 'REGEX: ' . $search;

                                                for ($i = 0; $i < count($match[0]); $i++) {
                                                    $log[] = 'LINE: ' . (substr_count(substr($modification[$key], 0, $match[0][$i][1]), "\n") + 1);
                                                }

                                                $status = true;
                                            }

                                            // Make the modification
                                            $modification[$key] = preg_replace($search, $replace, $modification[$key], $limit);
                                        }

                                        if (!$status) {
                                            // Abort applying this modification completely.
                                            if ($error == 'abort') {
                                                $modification = $recovery;
                                                // Log
                                                $log[] = 'NOT FOUND - ABORTING!';
                                                break 5;
                                            }
                                            // Skip current operation or break
                                            elseif ($error == 'skip') {
                                                // Log
                                                $log[] = 'NOT FOUND - OPERATION SKIPPED!';
                                                continue;
                                            }
                                            // Break current operations
                                            else {
                                                // Log
                                                $log[] = 'NOT FOUND - OPERATIONS ABORTED!';
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // Log
                $log[] = '----------------------------------------------------------------';
            }

            // Log
            $ocmod = new Log('ocmod.log');
            $ocmod->write(implode("\n", $log));

            // Write all modification files
            foreach ($modification as $key => $value) {
                // Only create a file if there are changes
                if ($original[$key] != $value) {
                    $path = '';

                    $directories = explode('/', dirname($key));

                    foreach ($directories as $directory) {
                        $path = $path . '/' . $directory;

                        if (!is_dir(DIR_MODIFICATION . $path)) {
                            @mkdir(DIR_MODIFICATION . $path, 0777);
                        }
                    }

                    $handle = fopen(DIR_MODIFICATION . $key, 'w');

                    fwrite($handle, $value);

                    fclose($handle);
                }
            }

            // Maintance mode back to original settings
            $this->model_setting_setting->editSettingValue('config', 'config_maintenance', $maintenance);

            // Do not return success message if refresh() was called with $data
            $this->session->data['success'] = $this->language->get('text_success');

            $url = '';

            if (isset($this->request->get['sort'])) {
                $url .= '&sort=' . $this->request->get['sort'];
            }

            if (isset($this->request->get['order'])) {
                $url .= '&order=' . $this->request->get['order'];
            }

            if (isset($this->request->get['page'])) {
                $url .= '&page=' . $this->request->get['page'];
            }

        }

    }

I hope it shouwl work for you.
This process is used to refresh the modification when your module installing.

if you need globally this then please tell me  I will update you process.


问:
Need to load an aspx page on broswer close event
Hi I Need to load an aspx page on broswer close event . I tried the following code. But it does not seem to work. Can anyone help me out with this. Thanks

```<code> var clicked = false;
    function CheckBrowser() {
        if (clicked == false) {
            //Browser closed
        } else {
            //redirected
            clicked = false;
        }
    }
    function bodyUnload() {
        alert(1);
        alert(clicked);
        if (clicked == false)//browser is closed
        {
            alert(clicked);
            var request = GetRequest();
            request.open("POST", "..Security/Logout.aspx", false);
            //Send the proper header information along with the request
            request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            request.send();
        }
    }

    function GetRequest() {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        return xmlhttp;
    }
</code>```

答:
I tried this and my issue was resolved

```<code>var clicked = false;

    function bodyUnload() {
        alert(1);
        if (clicked == false)//browser is closed
        {
            var request = GetRequest();
            request.open("GET", "../TestLogout.aspx", true);
            request.send();
        }
    }

    function GetRequest() {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        return xmlhttp;
    }
</code>```

Thanks

Body:
Hi I Need to load an aspx page on broswer close event . I tried the following code. But it does not seem to work. Can anyone help me out with this. Thanks

 var clicked = false;
    function CheckBrowser() {
        if (clicked == false) {
            //Browser closed
        } else {
            //redirected
            clicked = false;
        }
    }
    function bodyUnload() {
        alert(1);
        alert(clicked);
        if (clicked == false)//browser is closed
        {
            alert(clicked);
            var request = GetRequest();
            request.open("POST", "..Security/Logout.aspx", false);
            //Send the proper header information along with the request
            request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            request.send();
        }
    }

    function GetRequest() {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        return xmlhttp;
    }

Body:
I tried this and my issue was resolved

var clicked = false;

    function bodyUnload() {
        alert(1);
        if (clicked == false)//browser is closed
        {
            var request = GetRequest();
            request.open("GET", "../TestLogout.aspx", true);
            request.send();
        }
    }

    function GetRequest() {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        return xmlhttp;
    }

Thanks


问:
5. 1.1 Legal: Privacy - Data Collection and Storage
We noticed that your app requires users to register with personal information to access non account-based features. Apps cannot require user registration prior to allowing access to app content and features that are not associated specifically to the user.

We are taking Email id on SignUp because all data is tracking in Backend behalf on Email id. What to do? Please anybody help me.

答: I think Apple does not know where you are using Email ID...So to solve this issue what you can do is you can send the otp to users Email Address to verify valid user and you can give the reason as  After the user order is confirmed you are going to send order confirmation mail and there Bill details in their Email id....Just mention all this Terms and condition in one screen what i have said above.I hope it helps..Thanks.</p>

ContentLicense: CC BY-SA 4.0


问:
Hive Query FAILED: ParseException line cannot recognize input near '(' 'WITH' 'DATA_SET' in select clause
I get a failure upon compiling a Hive View query using "WITH" Clause in the select statement. Below is the same view which I try to create and I encounter the error.

```<code>create view test_view as(
with data_set as
(select * from test_data )
select * from data_set
) ;
</code>```

Error - Error while compiling statement: FAILED: ParseException line 1:24 cannot recognize input near '(' 'with' 'data_set' in select
  clause

Please help.

答:
Issue is due to the bracket :)

once I remove the bracket from after create view view_name as (*.. it stated working...

Body:
I get a failure upon compiling a Hive View query using "WITH" Clause in the select statement. Below is the same view which I try to create and I encounter the error.

create view test_view as(
with data_set as
(select * from test_data )
select * from data_set
) ;

Error - Error while compiling statement: FAILED: ParseException line 1:24 cannot recognize input near '(' 'with' 'data_set' in select
  clause

Please help.


问:
Error just on host, not on my computer; String was not recognized as a valid DateTime
I am in bad situation. I have a program that it works very well in my computer but when I upload it on the host it gives me this error "String was not recognized as a valid DateTime." my program is on ASP.net C# visual studio 2015

Edit:
  both date's format on my computer and on the host are the same. like
  this:"mm/dd/yyyy"

would you please help me?
here is my code:
HTML:

<%@ Page Title="" Language="C#" MasterPageFile="~/mainMembers/frameMembers.Master" AutoEventWireup="true" CodeBehind="GMList.aspx.cs" Inherits="Federation.mainMembers.GMList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainFrame" runat="server">
    <form id="gml" runat="server" method="post">
        <asp:Label ID="titr" runat="server" CssClass="shekaste" Text="title"></asp:Label>

        <asp:GridView ID="fedList" runat="server" AutoGenerateColumns="false" CssClass="parastoo" OnRowDataBound="MatchList_RowDataBound" >
            <Columns>

                <asp:BoundField HeaderText="a" DataField="birthday" />

                <asp:BoundField HeaderText="b" DataField="start_sport" />

                <asp:BoundField HeaderText="c" DataField="ToDate" />

            </Columns>
        </asp:GridView>

        </form>
</asp:Content>```
</div>
</div>
</p>

<ol start="2">
<li><p>C# code:</p>

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Globalization;
using System.Drawing;
using System.Text.RegularExpressions;
using System.IO;

namespace Federation.mainMembers
{

    public partial class GMList : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NSG"].ConnectionString);
        //SqlConnection con = new SqlConnection(conStr);
        DataSet ds = new DataSet();
        //private string strSQL;
        private SqlCommand com;
        SqlDataAdapter sda;
        // DateTime dtime;
        DataTable dt = new DataTable();
        //DataTable dt1 = new DataTable();
        PersianCalendar pc = new PersianCalendar();
        //string memberID = "1111111112";
        string matchID = "";
        Boolean[] age2 = new Boolean[6];
        Boolean[] weight = new Boolean[9];
        //Int16 morshedi = 0;
        byte[] img1 = new byte[0];

        Int16 level;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["FID"] != null)
            {
                matchID = this.Session["FID"].ToString();
                //memberID = this.Session["VID"].ToString();
                //morshedi = Convert.ToInt16(this.Session["VMID"].ToString());

                //string s;

                if (!Page.IsPostBack)
                {

                    //********************************************************
                    dt.Rows.Clear();
                    con.Close();
                    sda = new SqlDataAdapter("select birthday,start_sport,ToDate   from general_members ", con);
                    con.Close();

                    con.Open();
                    dt.Rows.Clear();
                    sda.Fill(dt);

                    con.Close();
                    //string dds=dt.Rows[0]["ToDate"].ToString();
                    DataView dv1 = new DataView(dt);

                    fedList.DataSource = dv1;

                    fedList.DataBind();

                }
            }
            else
            {
                Response.Redirect("~/a.aspx");
            }

        }

        protected void MatchList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Find the value in the c04_oprogrs column. You'll have to use
                // some trial and error here to find the right control. The line
                // below may provide the desired value but I'm not entirely sure.

                TableCell statusCell1 = e.Row.Cells[0];
                TableCell statusCell2 = e.Row.Cells[1];
                TableCell statusCell3 = e.Row.Cells[2];

                string dstr = "";
                int year, month, day;
                year = Convert.ToInt32(pc.GetYear(Convert.ToDateTime(statusCell1.Text)));
                month = Convert.ToInt32(pc.GetMonth(Convert.ToDateTime(statusCell1.Text)));
                day = Convert.ToInt32(pc.GetDayOfMonth(Convert.ToDateTime(statusCell1.Text)));
                dstr = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
                statusCell1.Text = dstr;

                year = Convert.ToInt32(pc.GetYear(Convert.ToDateTime(statusCell2.Text)));
                month = Convert.ToInt32(pc.GetMonth(Convert.ToDateTime(statusCell2.Text)));
                day = Convert.ToInt32(pc.GetDayOfMonth(Convert.ToDateTime(statusCell2.Text)));
                dstr = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
                statusCell2.Text = dstr;

                year = Convert.ToInt32(pc.GetYear(Convert.ToDateTime(statusCell3.Text)));
                month = Convert.ToInt32(pc.GetMonth(Convert.ToDateTime(statusCell3.Text)));
                day = Convert.ToInt32(pc.GetDayOfMonth(Convert.ToDateTime(statusCell3.Text)));
                dstr = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
                statusCell3.Text = dstr;

            }
        }
    }
}
```

答:
If your data returned from Sql is DateTime (datatype is datetime) then you can directly format date in your Gridview for date columns as below:

```<code><asp:BoundField HeaderText="Birth Date" DataField="birthday" DataFormatString="{0:yyyy/MM/dd}" HtmlEncode="false" >
</code>```

and delete your below code from RowDataBound event for all date columns

```<code>            int year, month, day;
            year = Convert.ToInt32(pc.GetYear(Convert.ToDateTime(statusCell1.Text)));
            month = Convert.ToInt32(pc.GetMonth(Convert.ToDateTime(statusCell1.Text)));
            day = Convert.ToInt32(pc.GetDayOfMonth(Convert.ToDateTime(statusCell1.Text)));
            dstr = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
            statusCell1.Text = dstr;
</code>```

Body:
I am in bad situation. I have a program that it works very well in my computer but when I upload it on the host it gives me this error "String was not recognized as a valid DateTime." my program is on ASP.net C# visual studio 2015

Edit:
  both date's format on my computer and on the host are the same. like
  this:"mm/dd/yyyy"

would you please help me?
here is my code:
HTML:

<%@ Page Title="" Language="C#" MasterPageFile="~/mainMembers/frameMembers.Master" AutoEventWireup="true" CodeBehind="GMList.aspx.cs" Inherits="Federation.mainMembers.GMList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainFrame" runat="server">
    <form id="gml" runat="server" method="post">
        <asp:Label ID="titr" runat="server" CssClass="shekaste" Text="title"></asp:Label>

        <asp:GridView ID="fedList" runat="server" AutoGenerateColumns="false" CssClass="parastoo" OnRowDataBound="MatchList_RowDataBound" >
            <Columns>

                <asp:BoundField HeaderText="a" DataField="birthday" />

                <asp:BoundField HeaderText="b" DataField="start_sport" />

                <asp:BoundField HeaderText="c" DataField="ToDate" />

            </Columns>
        </asp:GridView>

        </form>
</asp:Content>

C# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Globalization;
using System.Drawing;
using System.Text.RegularExpressions;
using System.IO;

namespace Federation.mainMembers
{

    public partial class GMList : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NSG"].ConnectionString);
        //SqlConnection con = new SqlConnection(conStr);
        DataSet ds = new DataSet();
        //private string strSQL;
        private SqlCommand com;
        SqlDataAdapter sda;
        // DateTime dtime;
        DataTable dt = new DataTable();
        //DataTable dt1 = new DataTable();
        PersianCalendar pc = new PersianCalendar();
        //string memberID = "1111111112";
        string matchID = "";
        Boolean[] age2 = new Boolean[6];
        Boolean[] weight = new Boolean[9];
        //Int16 morshedi = 0;
        byte[] img1 = new byte[0];

        Int16 level;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["FID"] != null)
            {
                matchID = this.Session["FID"].ToString();
                //memberID = this.Session["VID"].ToString();
                //morshedi = Convert.ToInt16(this.Session["VMID"].ToString());

                //string s;

                if (!Page.IsPostBack)
                {

                    //********************************************************
                    dt.Rows.Clear();
                    con.Close();
                    sda = new SqlDataAdapter("select birthday,start_sport,ToDate   from general_members ", con);
                    con.Close();

                    con.Open();
                    dt.Rows.Clear();
                    sda.Fill(dt);

                    con.Close();
                    //string dds=dt.Rows[0]["ToDate"].ToString();
                    DataView dv1 = new DataView(dt);

                    fedList.DataSource = dv1;

                    fedList.DataBind();

                }
            }
            else
            {
                Response.Redirect("~/a.aspx");
            }

        }

        protected void MatchList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Find the value in the c04_oprogrs column. You'll have to use
                // some trial and error here to find the right control. The line
                // below may provide the desired value but I'm not entirely sure.

                TableCell statusCell1 = e.Row.Cells[0];
                TableCell statusCell2 = e.Row.Cells[1];
                TableCell statusCell3 = e.Row.Cells[2];

                string dstr = "";
                int year, month, day;
                year = Convert.ToInt32(pc.GetYear(Convert.ToDateTime(statusCell1.Text)));
                month = Convert.ToInt32(pc.GetMonth(Convert.ToDateTime(statusCell1.Text)));
                day = Convert.ToInt32(pc.GetDayOfMonth(Convert.ToDateTime(statusCell1.Text)));
                dstr = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
                statusCell1.Text = dstr;

                year = Convert.ToInt32(pc.GetYear(Convert.ToDateTime(statusCell2.Text)));
                month = Convert.ToInt32(pc.GetMonth(Convert.ToDateTime(statusCell2.Text)));
                day = Convert.ToInt32(pc.GetDayOfMonth(Convert.ToDateTime(statusCell2.Text)));
                dstr = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
                statusCell2.Text = dstr;

                year = Convert.ToInt32(pc.GetYear(Convert.ToDateTime(statusCell3.Text)));
                month = Convert.ToInt32(pc.GetMonth(Convert.ToDateTime(statusCell3.Text)));
                day = Convert.ToInt32(pc.GetDayOfMonth(Convert.ToDateTime(statusCell3.Text)));
                dstr = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
                statusCell3.Text = dstr;

            }
        }
    }
}

Body:
If your data returned from Sql is DateTime (datatype is datetime) then you can directly format date in your Gridview for date columns as below:

<asp:BoundField HeaderText="Birth Date" DataField="birthday" DataFormatString="{0:yyyy/MM/dd}" HtmlEncode="false" >

and delete your below code from RowDataBound event for all date columns

            int year, month, day;
            year = Convert.ToInt32(pc.GetYear(Convert.ToDateTime(statusCell1.Text)));
            month = Convert.ToInt32(pc.GetMonth(Convert.ToDateTime(statusCell1.Text)));
            day = Convert.ToInt32(pc.GetDayOfMonth(Convert.ToDateTime(statusCell1.Text)));
            dstr = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
            statusCell1.Text = dstr;


问:
IF...<Sql query>....ELSE IF ....<Sql query>...Else
I am trying to use query in NamedParameterJdbcTemplate by writing a query with if condition for Postgresql.

I will be passing 2 parameters to the query, store and tot_store. I tried following query but it doesn't work. Any suggestion?

```<code>IF (:store=1)
BEGIN
    SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store asc;
END
ELSE IF (:store = 2)
BEGIN
    SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store asc;
END
ELSE
BEGIN
    SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store desc;
END
</code>```

The error says

```<code>syntax error at or near "IF"
</code>```

Thank you in advance

答:
If you are using Mysql, there is incorrect IF statement in your code.
Correct IF syntax:

```<code>IF search_condition THEN statement_list
    [ELSEIF search_condition THEN statement_list] ...
    [ELSE statement_list]
END IF
</code>```

You need to get rid of brackets and put THEN after condition.

For example you can write such stored procedure:

```<code>DELIMITER //

CREATE FUNCTION SimpleCompare(n INT, m INT)
  RETURNS VARCHAR(20)

  BEGIN
    DECLARE s VARCHAR(20);

    IF n > m THEN SET s = '>';
    ELSEIF n = m THEN SET s = '=';
    ELSE SET s = '<';
    END IF;

    SET s = CONCAT(n, ' ', s, ' ', m);

    RETURN s;
  END //

DELIMITER ;
</code>```

Note, that in Mysql there is another IF. It is a function which can be used in select statements.

Official docs: https://dev.mysql.com/doc/refman/5.7/en/if.html

Body:
I am trying to use query in NamedParameterJdbcTemplate by writing a query with if condition for Postgresql.

I will be passing 2 parameters to the query, store and tot_store. I tried following query but it doesn't work. Any suggestion?

IF (:store=1)
BEGIN
    SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store asc;
END
ELSE IF (:store = 2)
BEGIN
    SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store asc;
END
ELSE
BEGIN
    SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store desc;
END

The error says

syntax error at or near "IF"

Thank you in advance

Body:
If you are using Mysql, there is incorrect IF statement in your code.
Correct IF syntax:

IF search_condition THEN statement_list
    [ELSEIF search_condition THEN statement_list] ...
    [ELSE statement_list]
END IF

You need to get rid of brackets and put THEN after condition.

For example you can write such stored procedure:

DELIMITER //

CREATE FUNCTION SimpleCompare(n INT, m INT)
  RETURNS VARCHAR(20)

  BEGIN
    DECLARE s VARCHAR(20);

    IF n > m THEN SET s = '>';
    ELSEIF n = m THEN SET s = '=';
    ELSE SET s = '<';
    END IF;

    SET s = CONCAT(n, ' ', s, ' ', m);

    RETURN s;
  END //

DELIMITER ;

Note, that in Mysql there is another IF. It is a function which can be used in select statements.

Official docs: https://dev.mysql.com/doc/refman/5.7/en/if.html


问:
string with a new line save in file in one line only
I am writting a code in C++. And I have a string like this

```<code>std::string1 = "one
                     two
                          end"
</code>```

this string has got a 2 newline. I want to save this string in the one  line of file. for example:

```<code>std::string2 = "one\ntwo\nend"
</code>```

End after I read from file this line and I change again string2 like a string1.

Do you know how I can do this??

My problem is to call the function to create a random strings and these strings maybe have got a newlines but I want to save and read from file the only one line. And this reason I don't know the string because it is random.

答:
You can use raw string literals for this:

```<code>std::string1 myString = R"__(one
two
three)__";
</code>```

The two underscores __ work as delimiters which can be chosen freely. Use the same in the beginning and the end of the raw string literal.
Also notice that anything in between will become part of the string, including all whitespace characters.

Body:
I am writting a code in C++. And I have a string like this

std::string1 = "one
                     two
                          end"

this string has got a 2 newline. I want to save this string in the one  line of file. for example:

std::string2 = "one\ntwo\nend"

End after I read from file this line and I change again string2 like a string1.

Do you know how I can do this??

My problem is to call the function to create a random strings and these strings maybe have got a newlines but I want to save and read from file the only one line. And this reason I don't know the string because it is random.

Body:
You can use raw string literals for this:

std::string1 myString = R"__(one
two
three)__";

The two underscores __ work as delimiters which can be chosen freely. Use the same in the beginning and the end of the raw string literal.
Also notice that anything in between will become part of the string, including all whitespace characters.


问:
Jenkins Orchestrate the set of some job in CI/CD
Dependency is :

When Job A finished it will start Job B and Job C then Job C starts Job D And when Job D and Job B finishes then only We need to start the Job E.

Please suggest how I can achieve this.

答: Join plugin along with build pipeline plugin :)</p>


问:
$.ajax does not delete multiple table rows with checkbox
I'm currently struggling as to why my code does not do the following multiple table row deletion php code:

```<code>incude("dbconnect.php");

if (isset($_POST["id"])) {

    foreach ($_POST["id"] as $id) {

        $sql = "DELETE FROM doctor WHERE DOC_LICENSE_NUM='.$id.'";

        if ($mydatabase->mysqli_query($sql) === TRUE) {
            echo "<div>Record deleted successfully</div>";
        } else {
            echo "Error deleting record: " . $mydatabase->error;
        }
        //$sql="DELETE from DOCTOR where DOC_LICENSE_NUM='".$id."'";
        //mysqli->query($connect, $sql);
    }
    //mysqli->close();
}
</code>```

whereas dbconnect links $mydatabase to the sql. Now, I created a button with the id btn_delete in order to use javascript click function in handling multiple rows to delete in my sql.

```<code><div style="float: right; margin: 0px 10px 10px 0px;"><button type="button" name="btn_delete" class="btn" id="btn_delete" ><span class="fa fa-trash" style="font-size:16px; margin-right:5px;"></span>Delete Multiple</button></div>
</code>```

What I did is that I used $.ajax in order to gather the checked checkboxes in an array and using the url for my php for deleting rows in the table and if it has entered the php it will proceed to fade the rows out of the table.

```<code>$('#btn_delete').click(function(){
    if(confirm("Are you sure you want to delete these?")){
        var id=[];
        $(':checkbox:checked').each(function(i){
            id[i]=$(this).val();
            //alert(id);
        });

        if(id.length===0){
            alert("Please select at least two checkboxes");
        }else{
            $.ajax({
                url:'muldel.php',
                method: 'POST',
                data: {id:id},
                success: function(){
                    for (var i=0; i<id.length; i++){
                        $('tr#'+id[i]+'').css('background-color', '#ccc');
                        $('tr#'+id[i]+'').fadeOut('slow');
                    }
                    //location.reload();
                }

            });
        }
    }else{
        return false;
    }
});
</code>```

However, when it proceeds to fade the row out of my tables, after I refresh it, it does not delete the rows like how I expected it to. What am I missing out here? (I forgot to mention that I used a unique entity key as my id)

答:
You can use below query to delete multiple records.

```<code>$sql = "DELETE FROM doctor WHERE DOC_LICENSE_NUM IN (" . implode(',', $_POST['id']) . ")";
if ($mydatabase->mysqli_query($sql) === TRUE) {
    echo "<div>Record deleted successfully</div>";
} else {
    echo "Error deleting record: " . $mydatabase->error;
}
</code>```

There is no need to iterate loop.

Body:
I'm currently struggling as to why my code does not do the following multiple table row deletion php code:

incude("dbconnect.php");

if (isset($_POST["id"])) {

    foreach ($_POST["id"] as $id) {

        $sql = "DELETE FROM doctor WHERE DOC_LICENSE_NUM='.$id.'";

        if ($mydatabase->mysqli_query($sql) === TRUE) {
            echo "
Record deleted successfully
";
        } else {
            echo "Error deleting record: " . $mydatabase->error;
        }
        //$sql="DELETE from DOCTOR where DOC_LICENSE_NUM='".$id."'";
        //mysqli->query($connect, $sql);
    }
    //mysqli->close();
}

whereas dbconnect links $mydatabase to the sql. Now, I created a button with the id btn_delete in order to use javascript click function in handling multiple rows to delete in my sql.

<button type="button" name="btn_delete" class="btn" id="btn_delete" >Delete Multiple</button>

What I did is that I used $.ajax in order to gather the checked checkboxes in an array and using the url for my php for deleting rows in the table and if it has entered the php it will proceed to fade the rows out of the table.

$('#btn_delete').click(function(){
    if(confirm("Are you sure you want to delete these?")){
        var id=[];
        $(':checkbox:checked').each(function(i){
            id[i]=$(this).val();
            //alert(id);
        });

        if(id.length===0){
            alert("Please select at least two checkboxes");
        }else{
            $.ajax({
                url:'muldel.php',
                method: 'POST',
                data: {id:id},
                success: function(){
                    for (var i=0; i<id.length; i++){
                        $('tr#'+id[i]+'').css('background-color', '#ccc');
                        $('tr#'+id[i]+'').fadeOut('slow');
                    }
                    //location.reload();
                }

            });
        }
    }else{
        return false;
    }
});

However, when it proceeds to fade the row out of my tables, after I refresh it, it does not delete the rows like how I expected it to. What am I missing out here? (I forgot to mention that I used a unique entity key as my id)

Body:
You can use below query to delete multiple records.

$sql = "DELETE FROM doctor WHERE DOC_LICENSE_NUM IN (" . implode(',', $_POST['id']) . ")";
if ($mydatabase->mysqli_query($sql) === TRUE) {
    echo "<div>Record deleted successfully</div>";
} else {
    echo "Error deleting record: " . $mydatabase->error;
}

There is no need to iterate loop.


问:
Excel file downloadeb by google chrome
I have request which download excel file! And some texts into cell very big, and I am trying to divide it into several lines. And I am using xlwt in django: this is my code:

```<code>def parse_string(label=""):
if len(label) == 0:
    return "", 1
t = ""
mx_sym = 50
endl = 0
for i in label:
    if mx_sym > 0:
        t += i
        mx_sym -= 1
    elif mx_sym <= 0 and i != ' ':
        t += i
    elif mx_sym <= 0 and i == ' ':
        t += "\n"
        endl += 1
        mx_sym = 50
return t, endl
</code>```

this is my function to divide text into several lines

```<code>def single_doc_report_to_xls(file, report):
wb = xlwt.Workbook()
ws = wb.add_sheet(u'Отчет #')
al = xlwt.Alignment()
al.wrap = xlwt.Alignment.WRAP_AT_RIGHT

ws.write(0, 0, u"№ п/п")
ws.write(0, 1, u"Наименование документа")
ws.write(0, 2, u"Наличие документа")
ws.write(0, 3, u"Дата вложения документа")
ws.write(0, 4, u"Дата приема документа сотрудником ЦПМБ/ЦПСБ")
ws.write(0, 5, u"Комментарии по документу (при наличии)")
ws.write(0, 6, u"Статус документа (в обработке/ на доработке/ принят Банком для рассмотрения)")

ws.col(0).width = 256 * 60
ws.col(1).width = 256 * 65
ws.col(2).width = 256 * 60
ws.col(3).width = 256 * 20
ws.col(4).width = 256 * 60
ws.col(5).width = 256 * 60
ws.col(6).width = 256 * 60

index = 1
for r in report:
    ws.write(index, 0, r["num"])
    cur_mx = 1

    t, h = parse_string(r["description"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 1, t)

    t, h = parse_string(r["has_file"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 2, t)

    t, h = parse_string(r["create_timestamp"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 3, t)

    t, h = parse_string(r["status_timestamp"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 4, t)

    t, h = parse_string(r["comments"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 5, t)

    t, h = parse_string(r["status_display"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 6, t)

    ws.row(index).height_mismatch = True
    ws.row(index).height = 256 * max(3, cur_mx*2)
    index += 1

wb.save(file)
</code>```

above function to write data into excel, and everything works correctly when I download excel by mozilla, but for google chtore it does'nt work. And I don't know why. Please, help me.

this is excel file which download by mozilla

and this one by google chrome:

答:
This doesn't seem to be a Django question.

The files appear to be the same, but have different text wrapping applied to the cells (although my Cyrillic is v shakey).

The top one has opened using Excel that is auto wrapping inside the cell.  The latter, from Chrome, appears to be opening in Google Sheets or similar, with auto wrap turned off, although it's hard to tell with the way you've cropped the image.  If you go into your downloads folders and open both with Excel, you should see the same thing.  Your wrap is set in the file generation, but individual browsers and spreadsheet programmes can override with their local settings.

Title: Excel file downloadeb by google chrome

Body:
I have request which download excel file! And some texts into cell very big, and I am trying to divide it into several lines. And I am using xlwt in django: this is my code:

def parse_string(label=""):
if len(label) == 0:
    return "", 1
t = ""
mx_sym = 50
endl = 0
for i in label:
    if mx_sym > 0:
        t += i
        mx_sym -= 1
    elif mx_sym <= 0 and i != ' ':
        t += i
    elif mx_sym <= 0 and i == ' ':
        t += "\n"
        endl += 1
        mx_sym = 50
return t, endl

this is my function to divide text into several lines

def single_doc_report_to_xls(file, report):
wb = xlwt.Workbook()
ws = wb.add_sheet(u'Отчет #')
al = xlwt.Alignment()
al.wrap = xlwt.Alignment.WRAP_AT_RIGHT

ws.write(0, 0, u"№ п/п")
ws.write(0, 1, u"Наименование документа")
ws.write(0, 2, u"Наличие документа")
ws.write(0, 3, u"Дата вложения документа")
ws.write(0, 4, u"Дата приема документа сотрудником ЦПМБ/ЦПСБ")
ws.write(0, 5, u"Комментарии по документу (при наличии)")
ws.write(0, 6, u"Статус документа (в обработке/ на доработке/ принят Банком для рассмотрения)")

ws.col(0).width = 256 * 60
ws.col(1).width = 256 * 65
ws.col(2).width = 256 * 60
ws.col(3).width = 256 * 20
ws.col(4).width = 256 * 60
ws.col(5).width = 256 * 60
ws.col(6).width = 256 * 60

index = 1
for r in report:
    ws.write(index, 0, r["num"])
    cur_mx = 1

    t, h = parse_string(r["description"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 1, t)

    t, h = parse_string(r["has_file"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 2, t)

    t, h = parse_string(r["create_timestamp"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 3, t)

    t, h = parse_string(r["status_timestamp"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 4, t)

    t, h = parse_string(r["comments"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 5, t)

    t, h = parse_string(r["status_display"])
    cur_mx = max(cur_mx, h)
    ws.write(index, 6, t)

    ws.row(index).height_mismatch = True
    ws.row(index).height = 256 * max(3, cur_mx*2)
    index += 1

wb.save(file)

above function to write data into excel, and everything works correctly when I download excel by mozilla, but for google chtore it does'nt work. And I don't know why. Please, help me.

this is excel file which download by mozilla

and this one by google chrome:


问:
Django admin inline with custom queryset
I've got two models:

```<code>class Parent:
   ...

class Child:
   parent = models.ForeignKey(Parent)
</code>```

In the model admin of the Parent I want to show an inline of the Child with a custom queryset, not only the ones related to the parent through the fk field.

I've tried:

```<code>class ChildInline(admin.TabularInline):
   model = Child
   def get_queryset(self, request):
      return Child.objects.filter(<my custom filter>)

class ParentAdmin(admin.ModelAdmin):
   inlines = [ChildInline]
</code>```

But still the only children shown in the inline are the ones that fullfill both filters: related to the parent by the FK + my custom filter.

Is it possible to do this?

EDIT:

I've seen now is the BaseInlineFormSet who is filtering the queryset I compose to keep only childs related to the parent, any idea how to avoid this?

```<code>django/forms/models.py

class BaseInlineFormSet(BaseModelFormSet):
    ...
    if self.instance.pk is not None:
       qs = queryset.filter(**{self.fk.name: self.instance})
    ...
</code>```

答:
You have to override __init__() method of BaseInlineFormSet and update queryset there.

```<code>from django.forms.models import BaseInlineFormSet

class ChildInlineFormSet(BaseInlineFormSet):

    def __init__(self, *args, **kwargs):
        super(ChildInlineFormSet, self).__init__(*args, **kwargs)
        # Now we need to make a queryset to each field of each form inline
        self.queryset = Child.objects.filter(<my custom filter>)
</code>```

Then initialise formset attribute with ChildInlineFormSet

```<code>class ChildInline(admin.TabularInline):
    model = Child
    formset = ChildInlineFormSet
    extra = 0

</code>```

Body:
I've got two models:

class Parent:
   ...

class Child:
   parent = models.ForeignKey(Parent)

In the model admin of the Parent I want to show an inline of the Child with a custom queryset, not only the ones related to the parent through the fk field.

I've tried:

class ChildInline(admin.TabularInline):
   model = Child
   def get_queryset(self, request):
      return Child.objects.filter(<my custom filter>)

class ParentAdmin(admin.ModelAdmin):
   inlines = [ChildInline]

But still the only children shown in the inline are the ones that fullfill both filters: related to the parent by the FK + my custom filter.

Is it possible to do this?

EDIT:

I've seen now is the BaseInlineFormSet who is filtering the queryset I compose to keep only childs related to the parent, any idea how to avoid this?

django/forms/models.py

class BaseInlineFormSet(BaseModelFormSet):
    ...
    if self.instance.pk is not None:
       qs = queryset.filter(**{self.fk.name: self.instance})
    ...

Body:
You have to override __init__() method of BaseInlineFormSet and update queryset there.

from django.forms.models import BaseInlineFormSet

class ChildInlineFormSet(BaseInlineFormSet):

    def __init__(self, *args, **kwargs):
        super(ChildInlineFormSet, self).__init__(*args, **kwargs)
        # Now we need to make a queryset to each field of each form inline
        self.queryset = Child.objects.filter(<my custom filter>)

Then initialise formset attribute with ChildInlineFormSet

class ChildInline(admin.TabularInline):
    model = Child
    formset = ChildInlineFormSet
    extra = 0