You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
// this doSQL script is called from the addedit.php script
// its purpose is to use the CTimesheet class to interoperate with the database (store, edit)
/* the following variables can be retreived via POST from timesheet/addedit.php:
** int task_log_id	is '0' if a new database object has to be stored or the id of an existing log that should be overwritten or deleted in the db
** str task_log_name	the text of the quote that should be stored
*/
// create a new instance of the einstein class
$obj = new CTimesheet();
$msg = '';
// reset the message string
// bind the informations (variables) retrieved via post to the einstein object
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
if ($_POST['progresso']) {
    $id = $obj->task_log_task;
    $sql2 = "UPDATE tasks set task_percent_complete = 100 WHERE task_id=" . $id;
    db_exec($sql2);
}
if ($obj->task_log_task) {
    $id = $obj->task_log_task;
    $sql = "SELECT task_name FROM tasks WHERE task_id=" . $id;
    $task = db_loadList($sql);
    foreach ($task as $row) {
        $task_log_name = $row['task_name'];
    }
    $obj->task_log_name = $task_log_name;