require_once '../assets/PHPWord-Master/src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
if ((isset($_POST['submit']) || isset($_POST['save'])) && isset($_SESSION['id_plancadre'])) {
    $update = true;
    $pdo = dbConnect();
    $pdo->beginTransaction();
    try {
        if (isset($_POST['sections_effacer']) && !empty($_POST['sections_effacer'])) {
            foreach ($_POST['sections_effacer'] as $section_id) {
                enleverSection($section_id, $pdo);
            }
        }
        if (isset($_POST['titres']) && !empty($_POST['titres'])) {
            foreach ($_POST['textes'] as $i => $texte) {
                $emplacement = $i + 1;
                updatesection($_POST["section_id"][$i], $emplacement, $_POST['titres'][$i], $pdo);
            }
        }
        if (isset($_POST['new_titres']) && !empty($_POST['new_titres'])) {
            $result = getcountsections($_SESSION['id_plancadre']);
            if (!empty($result)) {
                $new_emplacement = $result[0]['nbr'];
            } else {
                $new_emplacement = 1;
            }
            foreach ($_POST['new_textes'] as $i => $new_texte) {
                insert_section($_SESSION['id_plancadre'], $new_emplacement, $_POST['new_titres'][$i], $pdo);
                $new_emplacement++;
            }
        }
        if (isset($_POST['textes']) && !empty($_POST['textes'])) {
예제 #2
0
function addnewsection()
{
    //echo "<!-- into addnewtheme() -->\n";
    $newsection = getvardata("newsection", "", 99);
    $newname = getvardata("newname", "", 99);
    $newpic = getvardata("newpic", "menusection.gif", 99);
    $status = "Enter a name for the new section.";
    //echo "<!-- testing for empty newid[$newid] -->\n";
    if ($newsection != "") {
        $status = updatesection();
    }
    //echo "<!-- back into addnewtheme with [$status] -->\n";
    //echo "<!-- into add new theme with:";print_r($_SESSION);echo "-->\n";
    //echo "add new theme";
    echo "<table>\n";
    echo "<tr><td>Name of new Section?:</td>\n";
    echo "<td><input type=text name='newsection' id='newsection' value=\"{$newsection}\"></td></tr>\n";
    echo "<tr><td>Description of new Section?:</td>\n";
    echo "<td><input type=text name='newname' id='newname' value=\"{$newname}\"></td></tr>\n";
    echo "<tr><td>Section Icon file?:</td>\n";
    echo "<td><input type=text name='newpic' id='newpic' value=\"{$newpic}\"></td></tr>\n";
    echo "<tr><td colspan=2><input type=button name='ubtn' id='ubtn' value='Update' onclick=\"nextaction('update');\"> &nbsp; \n";
    echo "<input type=button name='qbtn' id='qbtn' value='Done' onclick=\"oops()\"></td></tr>\n";
    echo "<tr><td colspan=2><span name='status' id='status' class=''>{$status}</span></td></tr>\n";
    echo "</table>\n";
    setfocus("newsection");
}