} } // update rows in database if (isset($_POST["update"])) { $date = $_POST[SpecialDays::DATE]; $message = $_POST[SpecialDays::MESSAGE]; $id = $_POST[SpecialDays::ROW_ID]; $obj = new SpecialDay($id, $date, $message, null, "true"); $table = new SpecialDays(); if ($table->update($obj)) { echo "true"; } else { echo "false"; } } // delete rows in database if (isset($_POST["delete"])) { $id = $_POST[SpecialDays::ROW_ID]; $table = new SpecialDays(); if ($table->delete($id)) { echo "true"; } else { echo "false"; } } // fetch total rows if (isset($_GET["total"])) { $table = new SpecialDays(); $total = $table->totalRows(); echo $total . " reassure"; }
<th>Message</th> <th>Synced</th> <th>Actions</th> </tr> </thead> <tbody> <?php /** * Created by PhpStorm. * User: evolutionarycoder * Date: 2/19/16 * Time: 6:45 PM */ use Backend\Database\Tables\SpecialDays; use Backend\Helpers\TableBuilder; $table = new SpecialDays(); $data = $table->readAll(); $builder = new TableBuilder(); if ($data !== false) { for ($i = 0; $i < count($data); $i++) { $decoded = clone $data[$i]; $table->stripAndDecode($decoded); $table->strip($data[$i]); $current = $data[$i]; $builder->buildCell($decoded->getDate())->buildCell($decoded->getMessage())->buildCell($decoded->getSynced()); $builder->addActionAttrs("date", $current->getDate())->addActionAttrs("id", $current->getId())->addActionAttrs("message", $current->getMessage()); $builder->addRowAttr("id", $current->getId()); echo $builder->buildRow(); } } ?>
<?php /** * Created by PhpStorm. * User: evolutionarycoder * Date: 2/19/16 * Time: 7:10 PM */ header("Cache-Control: no-cache, no-store"); header("Pragma: no-cache"); use Backend\Database\Tables\SpecialDays; use Backend\Helpers\Email; include "../../../vendor/autoload.php"; if (isset($_GET["fetch"])) { $table = new SpecialDays(); if ($table->createJson()) { $email = new Email("MyLove Synced", "Table " . SpecialDays::TABLE_NAME); $email->send(); header("Location: ../json/" . SpecialDays::JSON_NAME); } else { echo "false"; } }