Good, moving forward a little more I came across another problem:
I have the following table:
Tabla1
+----+--------------------+-------------+-------+------------+
| Id | ultima_realizacion | vencimiento | tarea | id_cliente |
+----+--------------------+-------------+-------+------------+
- Five tasks are loaded per client (task1, task2, ..., task5).
- For each task, only 1 date must be loaded (in last_realization or in due date)
The choice of where to load is because there are:
- Monthly tasks (they are loaded in ultima_realizacion)
- Annual tasks (charged to expiration)
When I post in one field the other date should be yes or yes in '0000-00-00'
That is, if I load a date in " ultima_realizacion ", in the field " expiration " it goes '0000-00-00' and the same If you upload a date in " expiration ", in the field " ultima_realizacion ", go '0000-00-00' . p>
However, some monthly or annual tasks may not apply to a certain client.
Does not apply means that it is not taken into account for that client.
In that case:
- If it is monthly, in the field " ultima_realizacion " it goes '0001-01-01' and in " expiration " it remains > '0000-00-00'
- If it is annual, in the field " expiration " it goes '0001-01-01' and in " ultima_realizacion " it goes > '0000-00-00'
When I add a new client to this table, the date '0000-00-00' is automatically put to both date fields
That is, it is as follows:
Tabla1
+----+--------------------+-------------+-------+------------+
| Id | ultima_realizacion | vencimiento | tarea | id_cliente |
+----+--------------------+-------------+-------+------------+
1 0000-00-00 0000-00-00 1 1
2 0000-00-00 0000-00-00 2 1
3 0000-00-00 0000-00-00 3 1
4 0000-00-00 0000-00-00 4 1
5 0000-00-00 0000-00-00 5 1
If both dates " ultima_realizacion " and " expiration " are in '0000-00-00' , it means that the client was not set .
In that case you should show a message saying it was not set.
Now, if I have the following example:
Tabla1
+----+--------------------+-------------+-------+------------+
| Id | ultima_realizacion | vencimiento | tarea | id_cliente |
+----+--------------------+-------------+-------+------------+
1 0001-01-01 0000-00-00 tarea1 1
2 2016-08-10 0000-00-00 tarea2 1
3 0000-00-00 0001-01-01 tarea3 1
4 0000-01-01 0000-00-00 tarea4 1
5 0000-00-00 2016-10-01 tarea5 1
This means:
- "task1" is monthly and does not apply
- "tarea2" is mensaul and the date of "ultima_realizacion" was '2016-08-10'
- "tarea3" is annual and does not apply
- "tarea4" is monthly and does not apply
- "tarea5" is annual and the "expiration" date was '2016-10-01'
What I need is that:
- Show me if the client is set or not. In the previous example, the client is set, since the condition " WHERE ultima_realizacion = 000-00-00 AND expiration = 0000-00-00 " is not fulfilled.
- That the tasks that do not apply (which are 0001-01-01) do not influence me in the expiration formula that I will describe later.
- Let me know if there is at least 1 task due or not
Expiry formula.
If it's an annual task, I compare today's date with the "due date"
if (expiration